go-bond / bond

Other
10 stars 3 forks source link

Add ResetRetained to Batch #73

Closed marino39 closed 1 year ago

marino39 commented 1 year ago

It helps to reduce pressure on the GC by reusing data buffer within batch.

This resets b.data whenever it's size is bigger than 1MB. I would like to have my own policy for freeing this data. https://github.com/cockroachdb/pebble/blob/master/batch.go#L1095

marino39 commented 1 year ago

@poonai I don't want to code in any particular way of deciding if you want to retain data buffer or not. User can code whatever metric he wants to decide.

Batch.Len() returns size of the buffer

Batch.Reset() if you want to reset and clear buffer or Batch.ResetRetained() if you want to reset and keep the buffer