Waterpine opened a new pull request, #331:
URL: https://github.com/apache/datasketches-rust/pull/331

   ## Summary
   
   When `FrequentItemsSketch` grows its map, it re-inserted every key through 
`adjust_or_put_value`, which compares the key against each occupied slot on its 
probe path. The old keys are distinct by construction, so rehashing now uses 
`insert_absent`, which follows the same probe sequence and drift counting but 
skips the key comparisons. The resulting table is identical.
   
   On the benchmark machine this makes updates that include map growth take 5% 
to 10% less time: a time ratio of 0.95 for integer keys and 0.90 for 32-byte 
keys. Peak heap, allocation counts, and retained heap are unchanged.
   
   ## Results
   
   Main benchmark suite, 6 rounds. The ratio is the time after this change 
divided by the time before; below 1 is faster.
   
   | benchmark | time ratio |
   | --- | --- |
   | `frequencies::update::bytes_32` | 0.90 |
   | `frequencies::update::u64` | 0.95 |
   
   ## Scope of the results
   
   The change affects only the rehash that runs when the map grows. The 
benchmarks insert 10,000 distinct keys into a map that can hold up to 16,384, 
so they include the whole growth phase, which is the best case for this change. 
A stream with many repeated keys, or a sketch whose map has stopped growing, 
rehashes rarely or never and gains little. The saving grows with the cost of 
comparing keys: it is larger for 32-byte keys than for integers. It removes 
work rather than relying on a CPU feature, but the numbers come from one 
machine and I have not measured others.
   
   ## Checks
   
   `cargo x check`, `cargo x lint`, `cargo x test`, and `cargo +1.86.0 check -p 
datasketches --all-features` pass.
   
   Measured with Divan on one machine (2x Xeon E5-2660 v3, Linux 6.8) against 
`bb6ba57`, using paired rounds that alternate sockets; ratios are the geometric 
mean of per-round median ratios. The branch is based on upstream `main` at 
`4ba130e`; the numbers were not repeated there, because the commits in between 
change HLL and XOR code, benchmark timing units, and two variable renames in 
KLL and t-digest.


-- 
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