From a1e761f1e226c60efe5fdb5cfcf57d73090c525d Mon Sep 17 00:00:00 2001 From: Aaditya Sondhi <20070511+aadityasondhi@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:22:13 -0400 Subject: [PATCH] kvflowtokentracker: remove gc of empty token queues This patch removes the deletion of empty `trackedList` to resuse it in future runs. Based on benchmarks this helps reduce the heap allocations in the package. On `kv0/enc=false/nodes=3/cpu=96` heap profiles, this brings it down to 0.1% from the original 0.3% and much lower than the 0.77% of the previous commit. Informs #104154. Release note: None --- pkg/kv/kvserver/kvflowcontrol/kvflowtokentracker/tracker.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/kv/kvserver/kvflowcontrol/kvflowtokentracker/tracker.go b/pkg/kv/kvserver/kvflowcontrol/kvflowtokentracker/tracker.go index 113807dac75e..38a24aec7a81 100644 --- a/pkg/kv/kvserver/kvflowcontrol/kvflowtokentracker/tracker.go +++ b/pkg/kv/kvserver/kvflowcontrol/kvflowtokentracker/tracker.go @@ -193,9 +193,6 @@ func (dt *Tracker) Untrack( log.Infof(ctx, "released %s flow control tokens for %d out of %d tracked deductions for pri=%s stream=%s, up to %s; %d tracked deduction(s) remain%s", tokens, untracked, trackedBefore, pri, dt.stream, upto, len(dt.trackedM[pri].items), remaining) } - if len(dt.trackedM[pri].items) == 0 { - delete(dt.trackedM, pri) - } if dt.lowerBound.Less(upto) { dt.lowerBound = upto