Skip to content

Commit

Permalink
Expand mem tracking to all cuIO benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
devavret committed Mar 31, 2021
1 parent b9147f4 commit 4664f9a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cpp/benchmarks/fixture/benchmark_fixture.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
16 changes: 15 additions & 1 deletion cpp/benchmarks/io/csv/csv_reader_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>

#include <benchmarks/common/generate_benchmark_input.hpp>
#include <benchmarks/common/memory_tracking_resource.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/io/cuio_benchmark_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
Expand Down Expand Up @@ -51,12 +52,18 @@ void BM_csv_read_varying_input(benchmark::State& state)
cudf_io::csv_reader_options const read_options =
cudf_io::csv_reader_options::builder(source_sink.make_source_info());

rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::read_csv(read_options);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

void BM_csv_read_varying_options(benchmark::State& state)
Expand Down Expand Up @@ -94,6 +101,10 @@ void BM_csv_read_varying_options(benchmark::State& state)

size_t const chunk_size = csv_data.size() / num_chunks;
cudf::size_type const chunk_row_cnt = view.num_rows() / num_chunks;
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
for (int32_t chunk = 0; chunk < num_chunks; ++chunk) {
Expand Down Expand Up @@ -124,8 +135,11 @@ void BM_csv_read_varying_options(benchmark::State& state)
cudf_io::read_csv(read_options);
}
}
rmm::mr::set_current_device_resource(mr);

auto const data_processed = data_size * cols_to_read.size() / view.num_columns();
state.SetBytesProcessed(data_processed * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

#define CSV_RD_BM_INPUTS_DEFINE(name, type_or_group, src_type) \
Expand Down
15 changes: 14 additions & 1 deletion cpp/benchmarks/io/csv/csv_writer_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>

#include <benchmarks/common/generate_benchmark_input.hpp>
#include <benchmarks/common/memory_tracking_resource.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/io/cuio_benchmark_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
Expand All @@ -42,6 +43,10 @@ void BM_csv_write_varying_inout(benchmark::State& state)
auto const view = tbl->view();

cuio_source_sink_pair source_sink(sink_type);
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::csv_writer_options options =
Expand All @@ -50,8 +55,10 @@ void BM_csv_write_varying_inout(benchmark::State& state)
.rows_per_chunk(1 << 14); // TODO: remove once default is sensible
cudf_io::write_csv(options);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

void BM_csv_write_varying_options(benchmark::State& state)
Expand All @@ -69,6 +76,10 @@ void BM_csv_write_varying_options(benchmark::State& state)

std::string const na_per(na_per_len, '#');
std::vector<char> csv_data;
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::csv_writer_options options =
Expand All @@ -78,8 +89,10 @@ void BM_csv_write_varying_options(benchmark::State& state)
.rows_per_chunk(rows_per_chunk);
cudf_io::write_csv(options);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

#define CSV_WR_BM_INOUTS_DEFINE(name, type_or_group, sink_type) \
Expand Down
16 changes: 15 additions & 1 deletion cpp/benchmarks/io/orc/orc_reader_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>

#include <benchmarks/common/generate_benchmark_input.hpp>
#include <benchmarks/common/memory_tracking_resource.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/io/cuio_benchmark_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
Expand Down Expand Up @@ -58,12 +59,18 @@ void BM_orc_read_varying_input(benchmark::State& state)
cudf_io::orc_reader_options read_opts =
cudf_io::orc_reader_options::builder(source_sink.make_source_info());

rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::read_orc(read_opts);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

std::vector<std::string> get_col_names(std::vector<char> const& orc_data)
Expand Down Expand Up @@ -112,6 +119,10 @@ void BM_orc_read_varying_options(benchmark::State& state)

auto const num_stripes = data_size / (64 << 20);
cudf::size_type const chunk_row_cnt = view.num_rows() / num_chunks;
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0

Expand Down Expand Up @@ -141,8 +152,11 @@ void BM_orc_read_varying_options(benchmark::State& state)

CUDF_EXPECTS(rows_read == view.num_rows(), "Benchmark did not read the entire table");
}
rmm::mr::set_current_device_resource(mr);

auto const data_processed = data_size * cols_to_read.size() / view.num_columns();
state.SetBytesProcessed(data_processed * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

#define ORC_RD_BM_INPUTS_DEFINE(name, type_or_group, src_type) \
Expand Down
15 changes: 14 additions & 1 deletion cpp/benchmarks/io/orc/orc_writer_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>

#include <benchmarks/common/generate_benchmark_input.hpp>
#include <benchmarks/common/memory_tracking_resource.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/io/cuio_benchmark_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
Expand Down Expand Up @@ -50,15 +51,21 @@ void BM_orc_write_varying_inout(benchmark::State& state)
auto const view = tbl->view();

cuio_source_sink_pair source_sink(sink_type);
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::orc_writer_options options =
cudf_io::orc_writer_options::builder(source_sink.make_sink_info(), view)
.compression(compression);
cudf_io::write_orc(options);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

void BM_orc_write_varying_options(benchmark::State& state)
Expand All @@ -75,6 +82,10 @@ void BM_orc_write_varying_options(benchmark::State& state)
auto const view = tbl->view();

cuio_source_sink_pair source_sink(io_type::FILEPATH);
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::orc_writer_options const options =
Expand All @@ -83,8 +94,10 @@ void BM_orc_write_varying_options(benchmark::State& state)
.enable_statistics(enable_stats);
cudf_io::write_orc(options);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

#define ORC_WR_BM_INOUTS_DEFINE(name, type_or_group, sink_type) \
Expand Down
16 changes: 15 additions & 1 deletion cpp/benchmarks/io/parquet/parquet_reader_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>

#include <benchmarks/common/generate_benchmark_input.hpp>
#include <benchmarks/common/memory_tracking_resource.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/io/cuio_benchmark_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
Expand Down Expand Up @@ -58,12 +59,18 @@ void BM_parq_read_varying_input(benchmark::State& state)
cudf_io::parquet_reader_options read_opts =
cudf_io::parquet_reader_options::builder(source_sink.make_source_info());

rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer const raii(state, true); // flush_l2_cache = true, stream = 0
cudf_io::read_parquet(read_opts);
}
rmm::mr::set_current_device_resource(mr);

state.SetBytesProcessed(data_size * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

std::vector<std::string> get_col_names(std::vector<char> const& parquet_data)
Expand Down Expand Up @@ -112,6 +119,10 @@ void BM_parq_read_varying_options(benchmark::State& state)

auto const num_row_groups = data_size / (128 << 20);
cudf::size_type const chunk_row_cnt = view.num_rows() / num_chunks;
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource();
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr);

rmm::mr::set_current_device_resource(&tracking_mr);
for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0

Expand Down Expand Up @@ -141,8 +152,11 @@ void BM_parq_read_varying_options(benchmark::State& state)

CUDF_EXPECTS(rows_read == view.num_rows(), "Benchmark did not read the entire table");
}
rmm::mr::set_current_device_resource(mr);

auto const data_processed = data_size * cols_to_read.size() / view.num_columns();
state.SetBytesProcessed(data_processed * state.iterations());
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size();
}

#define PARQ_RD_BM_INPUTS_DEFINE(name, type_or_group, src_type) \
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/io/parquet/parquet_writer_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 4664f9a

Please sign in to comment.