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
if delme {
b.prev.next = nil
if cap(b.prev.data) == BufferCap {
bufferPool.Put(b.prev)
if cap(b.prev.data) != BufferCap {
b.prev.data = make([]schema.Float, 0, BufferCap)
}
bufferPool.Put(b.prev)
b.prev = nil
}
}

View File

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