From 3b71ed1b2f1985b517c4a034b01997ba5cfff588 Mon Sep 17 00:00:00 2001 From: Michael Baird Date: Tue, 7 Mar 2017 15:15:03 -0600 Subject: [PATCH] make the fragment cache ThresholdIndex a function at 90% of ThresholdLength --- fragment.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fragment.go b/fragment.go index fe04682dc..0b1734593 100644 --- a/fragment.go +++ b/fragment.go @@ -43,6 +43,9 @@ const ( // HashBlockSize is the number of bitmaps in a merkle hash block. HashBlockSize = 100 + + // Percentage of the ThresholdLength size to resort the cache at + ThresholdBufferPct = 0.9 ) const ( @@ -245,7 +248,7 @@ func (f *Fragment) openCache() error { case CacheTypeRanked: c := NewRankCache() c.ThresholdLength = f.cacheSize - c.ThresholdIndex = f.cacheSize - 500 + c.ThresholdIndex = int(float64(f.cacheSize) * ThresholdBufferPct) f.cache = c case CacheTypeLRU: f.cache = NewLRUCache(f.cacheSize)