From 2678fd40e1cdc718b3a672dc73f8e1765c107585 Mon Sep 17 00:00:00 2001 From: Manish R Jain <manishrjain@gmail.com> Date: Thu, 3 Mar 2016 01:45:29 +0000 Subject: [PATCH] Change how many keys we merge. Also, run gentlyMerge in a goroutine, so our memory monitor can call aggressivelyEvict in time. Also, with this change, the memory growth is a heck of a lot more controlled. --- posting/lists.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/posting/lists.go b/posting/lists.go index 06404607..01307e53 100644 --- a/posting/lists.go +++ b/posting/lists.go @@ -98,12 +98,12 @@ func aggressivelyEvict(ms runtime.MemStats) { Info("Memory Usage after calling GC.") } -func gentlyMerge(ms runtime.MemStats) { +func gentlyMerge() { ctr := NewCounters() defer ctr.ticker.Stop() - // Pick 1% of the dirty map or 400 keys, whichever is higher. - pick := int(float64(dirtymap.Size()) * 0.1) + // Pick 5% of the dirty map or 400 keys, whichever is higher. + pick := int(float64(dirtymap.Size()) * 0.05) if pick < 400 { pick = 400 } @@ -161,7 +161,8 @@ func checkMemoryUsage() { aggressivelyEvict(ms) } else { - gentlyMerge(ms) + // gentlyMerge can take a while to finish. So, run it in a goroutine. + go gentlyMerge() } } } -- GitLab