notfilippo opened a new pull request, #404: URL: https://github.com/apache/datasketches-rust/pull/404
Follow-up to #402 with the optimizations @tisonkun suggested in review. It builds on #402, so only the last two commits are new until #402 merges. ## Changes - `HllUnion::update` replays list and set sources with `update_with_coupons`, so a dense union picks its register format once per source instead of once per coupon. - `HashSet::update` is now `#[inline]`. Without it, the union change made LLVM stop inlining it into `HllSketch::update_with_coupon`, which then saved an extra register on every scalar update. On x86 that made dense `Hll4` updates up to 11% slower. - `Hll6` register access does one bounds check instead of two, and `register_position` is `#[inline]`, so the batch loop no longer calls it once per coupon. I left out `#[inline(never)]` on `update_coupons`. It sped up `Hll4` and `Hll8` batches on M1, but not on x86, where it made `Hll6` batches slower. ## Benchmarks CPU time relative to #402, so lower is faster. Each value is the median over 10 or 12 paired blocks, and every sample ran for at least 300 ms. Serialized bytes and estimates matched #402 in every case. Union of 400 sparse `Hll8` partials with 200 values each, the same workload as `hll::union::*_small_partials` (union change only): | Workload | M1 Max | Xeon 8259CL | | --- | --- | --- | | `persistent_small_partials/12` | 0.84 | 0.68 | | `persistent_small_partials/18` | 0.90 | 0.90 | | `recreated_small_partials/12` | 0.85 | 0.70 | | `recreated_small_partials/18` | 0.95 | 0.96 | Dense `Hll6` sketch at `lg_k` 14, 1M values in batches of 8,192 (`register_position` change only, distinct / duplicate-heavy input): | Workload | M1 Max | Xeon 8259CL | | --- | --- | --- | | `update_with_coupons` with precomputed coupons | 0.95 / 0.94 | 0.80 / 0.79 | | `update_with_coupons` with hashing | 0.96 / 0.97 | 0.94 / 0.95 | I checked for regressions with all of these changes plus the `#[inline(never)]` I left out, which doesn't touch scalar or sparse updates. Sparse sketch updates (50,000 and 5,000 groups) stayed within 1% of #402, and scalar `update` within 2%. Scalar `Hll6` `update` was about 4% faster on M1 and unchanged on x86. Precomputed `Hll8` `update_with_coupon` measured 8% slower on x86, but its machine code is identical to #402; only the function's alignment moved. The x86 builds used `-C llvm-args=-x86-branches-within-32B-boundaries`, because identical code otherwise moved by up to 35% depending on alignment. -- 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]
