Resize the buffers and put them into the pool

This commit is contained in:
Aditya Ujeniya
2026-02-16 18:21:45 +01:00
parent 2eeefc2720
commit 1cf2c41bd7
2 changed files with 6 additions and 4 deletions

View File

@@ -237,9 +237,10 @@ func (b *buffer) free(t int64) (delme bool, n int) {
n += m n += m
if delme { if delme {
b.prev.next = nil b.prev.next = nil
if cap(b.prev.data) == BufferCap { if cap(b.prev.data) != BufferCap {
bufferPool.Put(b.prev) b.prev.data = make([]schema.Float, 0, BufferCap)
} }
bufferPool.Put(b.prev)
b.prev = nil b.prev = nil
} }
} }

View File

@@ -189,9 +189,10 @@ func (l *Level) free(t int64) (int, error) {
delme, m := b.free(t) delme, m := b.free(t)
n += m n += m
if delme { if delme {
if cap(b.data) == BufferCap { if cap(b.data) != BufferCap {
bufferPool.Put(b) b.data = make([]schema.Float, 0, BufferCap)
} }
bufferPool.Put(b)
l.metrics[i] = nil l.metrics[i] = nil
} }
} }