Repository navigation
GH-55711: [C++][Parquet] More ALP benchmarking for different input data - #55714
Conversation
mapleFU
left a comment
There was a problem hiding this comment.
Emmm some rules are useless, and not all paths have compression ratio. 🤔
| template <typename T> | ||
| static std::vector<T> MakeAlpInput(int64_t length, int decimals, int exception_percent) { | ||
| std::default_random_engine gen(/*seed=*/42); | ||
| std::uniform_int_distribution<int64_t> dist_digits(0, 100000); |
There was a problem hiding this comment.
We have 1,4 as decimals, however, only [0, 100000) is used 🤔
There was a problem hiding this comment.
Fixed (now at line 740): removed the decimals sweep (single scale, 2 decimals) and the
digits now span the signed range [-100000, 100000].
| const T scale = static_cast<T>(std::pow(10.0, decimals)); | ||
| std::vector<T> values(length); | ||
| for (auto& v : values) { | ||
| v = dist_exception(gen) ? dist_random(gen) : static_cast<T>(dist_digits(gen)) / scale; |
There was a problem hiding this comment.
Float shows a much lower ratio at 0% exceptions (~1.2); I haven't investigated why
I think * static_cast<T>(std::pow(10.0, -decimals)) should be used in this scenario, since / 100.0f * 100.0f might not get the original value back ( 5.0f / 100.0f != 5.0f * 0.01f) ?
There was a problem hiding this comment.
Thanks, that was the cause. Data is now generated as digits * 10^-decimals, and the float
ratio at 0% exceptions went from ~1.2 to above 1.7.
| } | ||
|
|
||
| static void AlpCustomArguments(benchmark::internal::Benchmark* b) { | ||
| for (int num_values : {MIN_RANGE, MAX_RANGE}) { |
There was a problem hiding this comment.
Yes, now it uses CreateRange(MIN_RANGE, MAX_RANGE, 8), so the sizes are 1024, 4096,
32768 and 65536, the same as Range.
|
Would you mind me take over this? |
|
@NageshPatel978 Could you please wait for the reply from issue author before creating a PR? |
|
Sure, please go ahead and finish this PR — thanks for working on it! Here are a few concrete suggestions to make the benchmark suite leaner and more accurate (Some advices are written by ai and verified by me, maybe you can just follow the way of arrow-rs):
For reference, |
|
Also, as a small tip when sharing benchmark numbers in PRs. It's helpful to mention the CPU architecture and compiler (e.g. x86_64/ARM64, Clang/GCC version), since codegen/auto-vectorization and memory bandwidth can vary quite a bit across them. For example, decode number without exception might be memory bounded in current benchmark, and we have different memory bindwidth in different chips. |
|
Thanks @NageshPatel978 . I think this is adding a lot of benchmark variations (which makes benchmarks longer to run). Can we perhaps cut down on the parameters a bit? I would suggest:
|
Sumdiboii
left a comment
There was a problem hiding this comment.
Other than the number of benchmarks currently added...It looks good to me!
|
Thanks @pitrou , reduced as suggested: num-values {1024, 65536} and exception percent {0, 1, 10}. |
|
Emm it's ok to me for maximum 10% |
pitrou
left a comment
There was a problem hiding this comment.
+1, thank you @NageshPatel978 !
|
For the record, benchmark results here (AMD Zen 2 CPU): |
|
For the record, benchmark results on Apple M5 Max (arm64, Apple clang 21.0.0, Release build): |
Rationale for this change
The existing ALP benchmarks encode a single repeated value (64.0), so decoding does almost no real work and the numbers don't reflect real data (see #55711).
What changes are included in this PR?
Adds ALP encoding and decoding benchmarks for float and double with varied input:
Decimal values are signed, with 2 decimals, generated as
digits * 10^-decimals(how ALP decodes them) from a deterministicstd::mt19937_64. Encoding and decoding benchmarks both report acompression_ratiocounter. The existing constant-value benchmarks are unchanged.Are these changes tested?
Benchmarks only; no library code changed. Run on x86_64, AMD Ryzen 7 7435HS, Linux, GCC 16.2.0, Release build, CPU scaling enabled. Timings are approximate, and decode numbers with no exceptions may be memory-bandwidth-bound, so they will differ by chip.
Decoding, 65536 values:
Are there any user-facing changes?
No.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
I used Claude to help draft the benchmark code and this description. I built it, ran the benchmarks and checked the results myself.
PR code and description written by:
Reviewed before submission by: