Skip to content

Commit 925245c

Browse files
committed
debug.
1 parent 5baf5ca commit 925245c

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

src/common/io.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ char* PrivateMmapStream::Open(std::string path, bool read_only, std::size_t offs
212212
char* ptr{nullptr};
213213
auto view_start = offset / GetPageSize() * GetPageSize();
214214
auto view_size = length + (offset - view_start);
215-
std::cout << view_start << " size: " << view_size << std::endl;
215+
std::cout << "offset:" << offset << ", length:" << length << ", start:" << view_start << ", size:" << view_size << std::endl;
216+
// std::cout << view_start << " size: " << view_size << std::endl;
216217
#if defined(__linux__) || defined(__GLIBC__)
217218
int prot{PROT_READ};
218219
if (!read_only) {

src/data/sparse_page_raw_format.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class SparsePageRawFormat : public SparsePageFormat<T> {
2222
if (!fi->Read(&offset_vec)) {
2323
return false;
2424
}
25+
std::cout << "read size:" << offset_vec.size() << " back:" << offset_vec.back() << std::endl;
2526
auto& data_vec = page->data.HostVector();
2627
CHECK_NE(page->offset.Size(), 0U) << "Invalid SparsePage file";
2728
data_vec.resize(offset_vec.back());
@@ -37,6 +38,7 @@ class SparsePageRawFormat : public SparsePageFormat<T> {
3738

3839
size_t Write(const T& page, dmlc::Stream* fo) override {
3940
const auto& offset_vec = page.offset.HostVector();
41+
std::cout << "write size:" << offset_vec.size() << " back:" << offset_vec.back() << std::endl;
4042
const auto& data_vec = page.data.HostVector();
4143
CHECK(page.offset.Size() != 0 && offset_vec[0] == 0);
4244
CHECK_EQ(offset_vec.back(), page.data.Size());

src/data/sparse_page_source.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S> {
115115
}
116116
// An heuristic for number of pre-fetched batches. We can make it part of BatchParam
117117
// to let user adjust number of pre-fetched batches when needed.
118-
uint32_t constexpr kPreFetch = 4;
118+
uint32_t constexpr kPreFetch = 1;
119119

120120
size_t n_prefetch_batches = std::min(kPreFetch, n_batches_);
121121
CHECK_GT(n_prefetch_batches, 0) << "total batches:" << n_batches_;
@@ -132,7 +132,7 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S> {
132132
CHECK_LT(fetch_it, cache_info_->offset.size());
133133
ring_->at(fetch_it) = std::async(std::launch::async, [fetch_it, self, this]() {
134134
auto page = std::make_shared<S>();
135-
this->exec_.Run([&] {
135+
// this->exec_.Run([&] {
136136
common::Timer timer;
137137
timer.Start();
138138
std::unique_ptr<SparsePageFormat<S>> fmt{CreatePageFormat<S>("raw")};
@@ -144,7 +144,7 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S> {
144144
auto fi = std::make_unique<common::PrivateMmapStream>(n, true, offset, length);
145145
CHECK(fmt->Read(page.get(), fi.get()));
146146
LOG(INFO) << "Read a page in " << timer.ElapsedSeconds() << " seconds.";
147-
});
147+
// });
148148
return page;
149149
});
150150
}
@@ -174,6 +174,7 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S> {
174174
}
175175

176176
auto bytes = fmt->Write(*page_, fo.get());
177+
std::cout << "wrote: " << bytes << std::endl;
177178

178179
timer.Stop();
179180
LOG(INFO) << static_cast<double>(bytes) / 1024.0 / 1024.0 << " MB written in "

tests/cpp/common/test_io.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST(IO, PrivateMmapStream) {
103103
{
104104
std::unique_ptr<dmlc::Stream> fo{dmlc::Stream::Create(path.c_str(), "w")};
105105
for (std::size_t i = 0; i < n_batches; ++i) {
106-
std::size_t size = (i + 1) * 2;
106+
std::size_t size = (i + 1) * 8192;
107107
std::vector<T> data(size, 0);
108108
std::iota(data.begin(), data.end(), i * i);
109109

tests/cpp/test_main.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
int main(int argc, char ** argv) {
1212
xgboost::Args args {{"verbosity", "2"}};
1313
xgboost::ConsoleLogger::Configure(args);
14-
14+
::testing::GTEST_FLAG(filter) = "CPUHistogram.ExternalMemory*";
15+
// ::testing::GTEST_FLAG(filter) = "IO.PrivateMmapStream";
1516
testing::InitGoogleTest(&argc, argv);
1617
testing::FLAGS_gtest_death_test_style = "threadsafe";
1718
auto rmm_alloc = xgboost::SetUpRMMResourceForCppTests(argc, argv);

tests/cpp/tree/hist/test_histogram.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,8 @@ TEST(CPUHistogram, ExternalMemory) {
477477
int32_t constexpr kBins = 256;
478478
Context ctx;
479479

480+
std::cout << "l:" << __LINE__ << std::endl;
480481
TestHistogramExternalMemory(&ctx, BatchParam{kBins, common::Span<float>{}, false}, true, false);
481-
TestHistogramExternalMemory(&ctx, BatchParam{kBins, common::Span<float>{}, false}, true, true);
482-
483-
float sparse_thresh{0.5};
484-
TestHistogramExternalMemory(&ctx, {kBins, sparse_thresh}, false, false);
485-
TestHistogramExternalMemory(&ctx, {kBins, sparse_thresh}, false, true);
486-
sparse_thresh = std::numeric_limits<float>::quiet_NaN();
487-
TestHistogramExternalMemory(&ctx, {kBins, sparse_thresh}, false, false);
488-
TestHistogramExternalMemory(&ctx, {kBins, sparse_thresh}, false, true);
489482
}
490483
} // namespace tree
491484
} // namespace xgboost

0 commit comments

Comments
 (0)