From 033a666900a2b58f72a3050e63b02f1681e4f609 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Sat, 17 Aug 2024 01:35:47 +0800 Subject: [PATCH] [EM] Log the page size of ellpack. (#10713) --- src/common/timer.h | 14 +++++--------- src/data/ellpack_page.cu | 11 +---------- src/data/ellpack_page.cuh | 3 +-- src/data/ellpack_page_source.cu | 2 ++ 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/common/timer.h b/src/common/timer.h index 80748e7b8264..3308dfb653dd 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -1,18 +1,15 @@ -/*! - * Copyright by Contributors 2017-2019 +/** + * Copyright 2017-2024, XGBoost Contributors */ #pragma once #include + #include -#include #include #include #include -#include - -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; @@ -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 diff --git a/src/data/ellpack_page.cu b/src/data/ellpack_page.cu index 575bcd5ce9a5..b7ec72ad393c 100644 --- a/src/data/ellpack_page.cu +++ b/src/data/ellpack_page.cu @@ -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(page.cut)} { auto it = common::MakeIndexTransformIter( [&](size_t i) { return page.row_ptr[i + 1] - page.row_ptr[i]; }); @@ -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 feature_types) const { diff --git a/src/data/ellpack_page.cuh b/src/data/ellpack_page.cuh index f11bdfae1d97..af11dec3fc15 100644 --- a/src/data/ellpack_page.cuh +++ b/src/data/ellpack_page.cuh @@ -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 diff --git a/src/data/ellpack_page_source.cu b/src/data/ellpack_page_source.cu index 7ab4819e14e1..2927d028cf79 100644 --- a/src/data/ellpack_page_source.cu +++ b/src/data/ellpack_page_source.cu @@ -172,6 +172,8 @@ void EllpackPageSourceImpl::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(); } }