tisonkun opened a new pull request, #396: URL: https://github.com/apache/datasketches-rust/pull/396
`MurmurHash3X64128::write` previously copied trailing bytes shorter than 16 bytes into a `[u8; 16]` buffer before `finish128` read them back byte by byte. Even when `write` and `finish128` are inlined at `T: Hash` call sites, LLVM cannot forward loads across a variable-length `copy_from_slice` into stack memory, causing stack frame allocation, `_memcpy` calls, and store-to-load forwarding stalls on variable-length inputs such as `raw_bytes` slices and strings. This change packs buffered tail bytes into a `u128` register in little-endian bit order, reads partial 8-byte words via overlapping fixed-width loads (building on the partial-word load technique from #394), outlines the multi-write buffering path, and implements fixed-width integer `Hasher` methods directly on the register buffer. Single-write inputs such as `raw_bytes::from_slice`, `raw_bytes::from_str`, `raw_bytes::from_vec`, and `raw_bytes::from_string` now fold away the buffered branch at compile time and hash directly in registers across all MurmurHash3-backed sketches without introducing a separate byte-slice API. Supersedes #394. ### Benchmark results Apple M4 Max, macOS 26.6.2, `rustc 1.101.0-nightly (8006091eb 2026-10-17)`. Times are medians in milliseconds with full observed `min..max` ranges over 7 alternating pairs comparing `main` at `28d4f35` (with the new `variable_bytes` benchmark cases copied over so both revisions run identical inputs and round counts) against `b829f58`. | Scenario | Before, ms | After, ms | Ratio | | :------------------------------------ | -----------: | -----------: | ----: | | `hll::update::u64` | 256 (252..258) | 271 (265..283) | 1.06x | | `hll::update::bytes_32` | 247 (245..252) | 151 (146..161) | 0.61x | | `hll::update::variable_bytes` | 335 (332..341) | 151 (150..156) | 0.45x | | `cpc::update::u64` | 344 (338..354) | 243 (239..248) | 0.71x | | `cpc::update::bytes_32` | 277 (272..282) | 255 (250..258) | 0.92x | | `cpc::update::variable_bytes` | 318 (314..327) | 230 (227..238) | 0.72x | | `theta::update::u64` | 184 (177..194) | 185 (183..195) | 1.01x | | `theta::update::bytes_32` | 320 (317..324) | 249 (245..265) | 0.78x | | `theta::update::variable_bytes` | 298 (294..319) | 165 (162..179) | 0.55x | | `tuple::update::u64` | 273 (267..295) | 223 (209..226) | 0.82x | | `tuple::update::bytes_32` | 332 (325..339) | 265 (263..268) | 0.80x | | `tuple::update::variable_bytes` | 301 (290..303) | 175 (172..182) | 0.58x | | `frequencies::update::u64` | 179 (175..186) | 175 (169..179) | 0.98x | | `frequencies::update::bytes_32` | 293 (285..306) | 225 (217..242) | 0.77x | | `frequencies::update::variable_bytes` | 342 (317..357) | 144 (133..189) | 0.42x | For `hll::update::u64`, both revisions emit the exact same 129-instruction AArch64 sequence (and `HllSketch::update_with_coupon` does not touch `MurmurHash3X64128`), so the timing difference comes from binary code alignment shifts as surrounding functions shrink. ### Reproduction ```sh cargo x bench -- hll::update --repeat 7 --raw cargo x bench -- cpc::update --repeat 7 --raw cargo x bench -- theta::update --repeat 7 --raw cargo x bench -- tuple::update --repeat 7 --raw cargo x bench -- frequencies::update --repeat 7 --raw ``` -- 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]
