-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-39398: [C++][Parquet] DNM: benchmark for readLevels #39486
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,14 @@ class BenchmarkHelper { | |
NodePtr type = schema::Int32("b", repetition); | ||
|
||
if (repetition == Repetition::REQUIRED) { | ||
descr_ = std::make_unique<ColumnDescriptor>(type, 0, 0); | ||
descr_ = std::make_unique<ColumnDescriptor>(type, /*max_definition_level=*/0, | ||
/*max_repetition_level=*/0); | ||
} else if (repetition == Repetition::OPTIONAL) { | ||
descr_ = std::make_unique<ColumnDescriptor>(type, 1, 0); | ||
descr_ = std::make_unique<ColumnDescriptor>(type, /*max_definition_level=*/1, | ||
/*max_repetition_level=*/0); | ||
} else { | ||
descr_ = std::make_unique<ColumnDescriptor>(type, 1, 1); | ||
descr_ = std::make_unique<ColumnDescriptor>(type, /*max_definition_level=*/1, | ||
/*max_repetition_level=*/1); | ||
} | ||
|
||
// Vectors filled with random rep/defs and values to make pages. | ||
|
@@ -141,6 +144,35 @@ static void ColumnReaderReadBatchInt32(::benchmark::State& state) { | |
state.SetBytesProcessed(state.iterations() * helper.total_size()); | ||
} | ||
|
||
// Benchmarks ReadBatch for ColumnReader with the following parameters in order: | ||
// - repetition: 0 for REQUIRED, 1 for OPTIONAL, 2 for REPEATED. | ||
// - batch_size: sets how many values to read at each call. | ||
static void ColumnReaderReadLevels(::benchmark::State& state) { | ||
const auto repetition = static_cast<Repetition::type>(state.range(0)); | ||
const auto batch_size = static_cast<int64_t>(state.range(1)); | ||
|
||
BenchmarkHelper helper(repetition, /*num_pages=*/1, /*levels_per_page=*/16 * 80000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using one page to make it simple |
||
|
||
// Vectors to read the values into. | ||
std::vector<int32_t> read_values(batch_size, -1); | ||
std::vector<int16_t> read_defs(batch_size, -1); | ||
std::vector<int16_t> read_reps(batch_size, -1); | ||
for (auto _ : state) { | ||
state.PauseTiming(); | ||
Int32Reader* reader = helper.ResetColumnReader(); | ||
[[maybe_unused]] bool v = reader->HasNext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using hasNext to trigger initialization |
||
state.ResumeTiming(); | ||
int64_t num_levels = 0; | ||
do { | ||
int64_t values_read = 0; | ||
reader->ReadLevels(batch_size, read_defs.data(), read_reps.data(), &num_levels, | ||
&values_read); | ||
} while (num_levels != 0); | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * helper.total_size()); | ||
} | ||
|
||
// Benchmarks ReadRecords for RecordReader with the following parameters in order: | ||
// - repetition: 0 for REQUIRED, 1 for OPTIONAL, 2 for REPEATED. | ||
// - batch_size: sets how many values to read at each call. | ||
|
@@ -204,6 +236,11 @@ BENCHMARK(ColumnReaderReadBatchInt32) | |
->Args({1, 1000}) | ||
->Args({2, 1000}); | ||
|
||
BENCHMARK(ColumnReaderReadLevels) | ||
->ArgNames({"Repetition", "BatchSize"}) | ||
->Args({1, 1000}) | ||
->Args({2, 1000}); | ||
|
||
BENCHMARK(RecordReaderSkipRecords) | ||
->ArgNames({"Repetition", "BatchSize"}) | ||
->Args({0, 1000}) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making this private with a Test Peer that can be used in the benchmark, so we can check this PR in?