From 38fb0512c50a4556bfe603f10043e807716ec335 Mon Sep 17 00:00:00 2001 From: Jackson Owens Date: Fri, 10 Jan 2025 17:33:37 -0500 Subject: [PATCH] compact: save the resized valueBuf when saving values Previously saveValue would copy the current iteration value into valueBuf, but if valueBuf was grown to accommodate a larger value, valueBuf wasn't stored. This lead to repeated re-allocations of buffers sufficiently large to hold the iteration value. --- internal/compact/iterator.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/compact/iterator.go b/internal/compact/iterator.go index bea5f090a7..a4e3cce755 100644 --- a/internal/compact/iterator.go +++ b/internal/compact/iterator.go @@ -1294,7 +1294,8 @@ func (i *Iter) saveValue() { i.err = err i.value = base.LazyValue{} } else if !callerOwned { - i.value = base.MakeInPlaceValue(append(i.valueBuf[:0], v...)) + i.valueBuf = append(i.valueBuf[:0], v...) + i.value = base.MakeInPlaceValue(i.valueBuf) } else { i.value = base.MakeInPlaceValue(v) }