pmcgleenon commented on PR #332: URL: https://github.com/apache/datasketches-rust/pull/332#issuecomment-6708016061
Hi @Waterpine @tisonkun I re-measured the change with the repository harness on two CPUs, with the PR cherry-picked onto `main` (`86eb143`) so both sides share the same harness. Medians of three alternating `bloom --repeat 10` runs; the ratio is PR time / main time, below 1 is faster. | scenario | Zen 3 (EPYC 7R13) | Kaby Lake (i5-7500) | | --- | --- | --- | | `bloom::update::u64` | 0.96 | 0.44 | | `bloom::update::bytes_32` | 1.03 | 0.54 | | `bloom::update::contains_and_insert_present_u64` | 0.94 | 0.46 | So the Haswell result reproduces (and then some) on Skylake-family cores, but on CPUs with a fast 64-bit divider the five multiplies cost about what the division did, and the 32-byte case is slightly slower because hashing already saturates the multiplier port. One more thing from profiling on the Zen 3 box: for `u64` items, `compute_hash` is a non-inlined 343-instruction function (about 40% of insert time) because the default `Hasher::write_u64` routes through the fully inlined streaming `write` and LLVM refuses to inline the hash. Overriding `write_u64` with a small body, marking `compute_hash` `#[inline]`, and reducing the shifted hash (always below 2^63) with a 64-bit multiplier and one shift instead of the 128-bit multiplier gives, relative to this PR: | scenario | Zen 3 | Kaby Lake | | --- | --- | --- | | `bloom::update::u64` | 0.71 | 0.70 | | `bloom::update::bytes_32` | 0.91 | 0.90 | | `bloom::update::contains_and_insert_present_u64` | 0.63 | 0.65 | Bit placement is unchanged and the placement digests pass. https://github.com/apache/datasketches-rust/compare/main...pmcgleenon:datasketches-rust:perf/bloom-hash-and-two-multiply -- 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]
