hisenyuan opened a new pull request, #2980:
URL: https://github.com/apache/datafusion-ballista/pull/2980

   # Which issue does this PR close?
   
   Closes #2979
   
   Related: apache/datasketches-rust#391. The precomputed-hash API proposed 
there remains a separate discussion.
   
   # Rationale for this change
   
   Ballista collects a distinct-count sketch as it writes shuffle output. For 
non-null Int64 keys, the current implementation writes the first hash for every 
row to a reusable buffer, then reads the hashes back into the sketch. 
Processing 16 keys at a time keeps the first hashes independent and feeds them 
to the same sketch update in row order, avoiding the full-batch buffer pass.
   
   Both hash steps are preserved.
   
   # What changes are included in this PR?
   
   - Add a writer-only fast path for non-null Int64 batches in the 
column-statistics stream shared by the shuffle writers.
   - On first use, compare the 16-value loop and its tail with DataFusion's 
`create_hashes`. Fall back to the existing path when that check fails, 
including when the DataFusion dependency forces hash collisions. Null-bearing 
batches and other Arrow types use the existing path.
   - Compare full serialized HLL sketches with the public `HyperLogLog::update` 
path. Cover batch boundaries, slices, nulls, repeated and extreme values, and 
the serialized sketch reported by the writer after union.
   
   ## Validation
   
   The reviewed candidate passed:
   
   - All 591 `ballista-core` library tests.
   - Three targeted byte comparisons with `datafusion/force_hash_collisions` 
enabled directly, and the same three through Ballista's `force_hash_collisions` 
feature.
   - The complete `dev/rust_lint.sh` script and `git diff --check`.
   
   ## Performance
   
   Compared with `a67ca065642fee85207377463b3f20e4d9f1a090` on an Apple M2 Max, 
macOS 15.6.1 arm64, Rust 1.95.0. Both binaries used `--profile release-nonlto`. 
Each input had 1M rows and a non-null Int64 partition key. The benchmark used 
one task, 200 output partitions, an 8,192-row batch size, and HLL precision 12.
   
   Each input used four warm-up rounds and 32 measured rounds with baseline and 
candidate alternated, both with and without HLL. Every run verified 1M output 
rows.
   
   | Distinct keys | HLL on, baseline → candidate | HLL off, baseline → 
candidate | Median paired reduction with HLL on |
   | --- | ---: | ---: | ---: |
   | 1,000,000 | 56.854 → 56.182 ms | 52.025 → 52.159 ms | 1.25% |
   | 80,000 | 43.819 → 42.983 ms | 38.667 → 38.902 ms | 2.24% |
   
   Times are arm medians; the last column is the median of per-round percentage 
reductions, not the ratio of those medians.
   
   After subtracting the paired HLL-off difference, the median savings were 
1.088 ms (95% bootstrap interval 0.446–1.327 ms) and 1.175 ms (0.783–1.864 ms). 
An earlier run on the same inputs measured 2.10% and 2.12% less wall time with 
HLL enabled.
   
   These intervals resample the 32 measured rounds. They do not cover 
correlations between rounds or variation between machines and independent run 
sessions. The adjusted difference is a comparison against the HLL-off control, 
not a direct measurement of HLL CPU time.
   
   The measured wall time covers one local sort-shuffle write from Parquet 
input through completion. The inputs are about 10 MB each and were repeatedly 
read without clearing the OS file cache. No spill was observed. Other input 
sizes, task concurrency, platforms, and distributed-query performance have not 
been measured.
   
   ## Reproduction materials
   
   The evidence is published separately in my fork and is not part of this PR's 
two-file diff:
   
   - [Build instructions, input generation, and rerun 
commands](https://github.com/hisenyuan/datafusion-ballista/blob/ba4bbce197b7e4f405515234eca49adca9e73ac2/hll-int64-benchmark-evidence/readme.md)
   - [Scripts, patches, raw samples, and build 
record](https://github.com/hisenyuan/datafusion-ballista/tree/ba4bbce197b7e4f405515234eca49adca9e73ac2/hll-int64-benchmark-evidence)
   - [Download the complete evidence 
ZIP](https://raw.githubusercontent.com/hisenyuan/datafusion-ballista/ba4bbce197b7e4f405515234eca49adca9e73ac2/hll-int64-benchmark-evidence/ballista-391-benchmark-evidence.zip)
   
   ZIP SHA-256: 
`7197573de5d174ca572f0ffe05d867aa15d00b910a54cf9cbc6a352fc933192e`.
   
   Both measured binaries used the same separate benchmark instrumentation 
patch to propagate stream errors and print elapsed seconds to six decimal 
places. The original benchmark prints only three decimal places, which is too 
coarse for these differences. Input generation uses DuckDB 1.5.0 with one 
thread; input checksums are included.
   
   The build record was assembled from retained files after the measurements. 
Per-run binary checksums and fast-path assertions were not recorded; sketch 
equivalence and fast-path selection were checked separately in tests. The 
evidence also contains an exploratory in-memory probe that bypasses the 
production wrapper and runtime guard; its results are not presented as 
production-path speedups.
   
   # Are there any user-facing changes?
   
   This changes an internal shuffle path. The sketch format, task-statistics 
schema, public API, and configuration remain unchanged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to