tsenart opened a new pull request, #78:
URL: https://github.com/apache/datasketches-go/pull/78

   The ItemsSketch.Update method and its compression helpers were
   allocating unnecessarily, causing significant GC pressure in
   high-throughput scenarios.
   
   Three changes:
   
   1. **Store minItem/maxItem by value instead of pointer.** The previous
      implementation used `*C` pointers and assigned `&item` on each update,
      causing the item parameter to escape to heap. Now we store values
      directly and use a `hasMinMax` bool to track initialization state.
   
   2. **In compressWhileUpdatingSketch, work on s.items directly** instead
      of calling `GetTotalItemsArray()` which copies the entire items slice.
      All operations (sort, halve, merge, shift) modify the array in
      place, so the copy was unnecessary.
   
   3. **In addEmptyTopLevelToCompletelyFullSketch, use s.levels and
      s.items directly** instead of `getLevelsArray()` and 
`GetTotalItemsArray()`.
      The copies were only used to read current state before growing.
   
   ### Benchmarks
   
   On a 500k item workload:
   
   | Metric | Before | After | Delta |
   |--------|--------|-------|-------|
   | time/op (KeyFuncNone) | 89ms | 34ms | **-62%** |
   | time/op (KeyFuncZorder) | 251ms | 187ms | **-26%** |
   | alloc/op (KeyFuncNone) | 472MB | 4.4MB | **-99%** |
   | alloc/op (KeyFuncZorder) | 611MB | 143MB | **-77%** |
   | allocs/op (KeyFuncNone) | 518,979 | 210 | **-99.96%** |
   | allocs/op (KeyFuncZorder) | 1,019,840 | 501,097 | **-51%** |
   
   All existing tests pass.


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