Skip to content

Commit

Permalink
[EM] Log the page size of ellpack. (#10713)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis authored Aug 16, 2024
1 parent abe65e3 commit 033a666
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
14 changes: 5 additions & 9 deletions src/common/timer.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
/*!
* Copyright by Contributors 2017-2019
/**
* Copyright 2017-2024, XGBoost Contributors
*/
#pragma once
#include <xgboost/logging.h>

#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

namespace xgboost {
namespace common {

namespace xgboost::common {
struct Timer {
using ClockT = std::chrono::high_resolution_clock;
using TimePointT = std::chrono::high_resolution_clock::time_point;
Expand Down Expand Up @@ -82,5 +79,4 @@ struct Monitor {
void Start(const std::string &name);
void Stop(const std::string &name);
};
} // namespace common
} // namespace xgboost
} // namespace xgboost::common
11 changes: 1 addition & 10 deletions src/data/ellpack_page.cu
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ EllpackPageImpl::EllpackPageImpl(Context const* ctx, GHistIndexMatrix const& pag
: is_dense{page.IsDense()},
base_rowid{page.base_rowid},
n_rows{page.Size()},
// This makes a copy of the cut values.
cuts_{std::make_shared<common::HistogramCuts>(page.cut)} {
auto it = common::MakeIndexTransformIter(
[&](size_t i) { return page.row_ptr[i + 1] - page.row_ptr[i]; });
Expand Down Expand Up @@ -540,15 +539,7 @@ void EllpackPageImpl::CreateHistIndices(DeviceOrd device,
// Return the number of rows contained in this page.
[[nodiscard]] bst_idx_t EllpackPageImpl::Size() const { return n_rows; }

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

EllpackDeviceAccessor EllpackPageImpl::GetDeviceAccessor(
DeviceOrd device, common::Span<FeatureType const> feature_types) const {
Expand Down
3 changes: 1 addition & 2 deletions src/data/ellpack_page.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ class EllpackPageImpl {

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

std::size_t MemCostBytes() const;

/**
* @brief Return the total number of symbols (total number of bins plus 1 for not
Expand Down
2 changes: 2 additions & 0 deletions src/data/ellpack_page_source.cu
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ void EllpackPageSourceImpl<F>::Fetch() {
Context ctx = Context{}.MakeCUDA(this->Device().ordinal);
*impl = EllpackPageImpl{&ctx, this->GetCuts(), *csr, is_dense_, row_stride_, feature_types_};
this->page_->SetBaseRowId(csr->base_rowid);
LOG(INFO) << "Generated an Ellpack page with size: " << impl->MemCostBytes()
<< " from a SparsePage with size:" << csr->MemCostBytes();
this->WriteCache();
}
}
Expand Down

0 comments on commit 033a666

Please sign in to comment.