Skip to content

Commit 033a666

Browse files
authored
[EM] Log the page size of ellpack. (dmlc#10713)
1 parent abe65e3 commit 033a666

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

src/common/timer.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
/*!
2-
* Copyright by Contributors 2017-2019
1+
/**
2+
* Copyright 2017-2024, XGBoost Contributors
33
*/
44
#pragma once
55
#include <xgboost/logging.h>
6+
67
#include <chrono>
7-
#include <iostream>
88
#include <map>
99
#include <string>
1010
#include <utility>
11-
#include <vector>
12-
13-
namespace xgboost {
14-
namespace common {
1511

12+
namespace xgboost::common {
1613
struct Timer {
1714
using ClockT = std::chrono::high_resolution_clock;
1815
using TimePointT = std::chrono::high_resolution_clock::time_point;
@@ -82,5 +79,4 @@ struct Monitor {
8279
void Start(const std::string &name);
8380
void Stop(const std::string &name);
8481
};
85-
} // namespace common
86-
} // namespace xgboost
82+
} // namespace xgboost::common

src/data/ellpack_page.cu

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ EllpackPageImpl::EllpackPageImpl(Context const* ctx, GHistIndexMatrix const& pag
356356
: is_dense{page.IsDense()},
357357
base_rowid{page.base_rowid},
358358
n_rows{page.Size()},
359-
// This makes a copy of the cut values.
360359
cuts_{std::make_shared<common::HistogramCuts>(page.cut)} {
361360
auto it = common::MakeIndexTransformIter(
362361
[&](size_t i) { return page.row_ptr[i + 1] - page.row_ptr[i]; });
@@ -540,15 +539,7 @@ void EllpackPageImpl::CreateHistIndices(DeviceOrd device,
540539
// Return the number of rows contained in this page.
541540
[[nodiscard]] bst_idx_t EllpackPageImpl::Size() const { return n_rows; }
542541

543-
// Return the memory cost for storing the compressed features.
544-
size_t EllpackPageImpl::MemCostBytes(size_t num_rows, size_t row_stride,
545-
const common::HistogramCuts& cuts) {
546-
// Required buffer size for storing data matrix in EtoLLPack format.
547-
size_t compressed_size_bytes =
548-
common::CompressedBufferWriter::CalculateBufferSize(row_stride * num_rows,
549-
cuts.TotalBins() + 1);
550-
return compressed_size_bytes;
551-
}
542+
std::size_t EllpackPageImpl::MemCostBytes() const { return this->gidx_buffer.size_bytes(); }
552543

553544
EllpackDeviceAccessor EllpackPageImpl::GetDeviceAccessor(
554545
DeviceOrd device, common::Span<FeatureType const> feature_types) const {

src/data/ellpack_page.cuh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ class EllpackPageImpl {
217217

218218
[[nodiscard]] bool IsDense() const { return is_dense; }
219219
/** @return Estimation of memory cost of this page. */
220-
static size_t MemCostBytes(size_t num_rows, size_t row_stride, const common::HistogramCuts&cuts) ;
221-
220+
std::size_t MemCostBytes() const;
222221

223222
/**
224223
* @brief Return the total number of symbols (total number of bins plus 1 for not

src/data/ellpack_page_source.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ void EllpackPageSourceImpl<F>::Fetch() {
172172
Context ctx = Context{}.MakeCUDA(this->Device().ordinal);
173173
*impl = EllpackPageImpl{&ctx, this->GetCuts(), *csr, is_dense_, row_stride_, feature_types_};
174174
this->page_->SetBaseRowId(csr->base_rowid);
175+
LOG(INFO) << "Generated an Ellpack page with size: " << impl->MemCostBytes()
176+
<< " from a SparsePage with size:" << csr->MemCostBytes();
175177
this->WriteCache();
176178
}
177179
}

0 commit comments

Comments
 (0)