File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const (
3232type CuckooTraceChecker struct {
3333 current * cuckoo.Filter
3434 future * cuckoo.Filter
35- mut sync.RWMutex
35+ mut sync.Mutex
3636 capacity uint
3737 met metrics.Metrics
3838 addch chan string
@@ -86,7 +86,7 @@ func NewCuckooTraceChecker(capacity uint, m metrics.Metrics) *CuckooTraceChecker
8686 batch = append (batch , t )
8787 // insert 100 traceIDs at a time to reduce
8888 // the amount of time this goroutine holding the write lock
89- for len (batch ) < 100 && len (c .addch ) > 0 {
89+ for len (batch ) < 1000 && len (c .addch ) > 0 {
9090 batch = append (batch , <- c .addch )
9191 }
9292
@@ -184,8 +184,8 @@ func (c *CuckooTraceChecker) Add(traceID string) {
184184
185185// Check tests if a traceID is (very probably) in the filter.
186186func (c * CuckooTraceChecker ) Check (traceID string ) bool {
187- c .mut .RLock ()
188- defer c .mut .RUnlock ()
187+ c .mut .Lock ()
188+ defer c .mut .Unlock ()
189189 return c .current .Lookup ([]byte (traceID ))
190190}
191191
@@ -197,13 +197,13 @@ func (c *CuckooTraceChecker) Maintain() {
197197 c .drain ()
198198
199199 var futureLoadFactor float64
200- c .mut .RLock ()
200+ c .mut .Lock ()
201201 currentLoadFactor := c .current .LoadFactor ()
202202 if c .future != nil {
203203 futureLoadFactor = c .future .LoadFactor ()
204204 }
205205 currentCapacity := c .capacity
206- c .mut .RUnlock ()
206+ c .mut .Unlock ()
207207
208208 // once the current one is half loaded, we can start using the future one too
209209 if futureLoadFactor == 0 && currentLoadFactor > 0.5 {
You can’t perform that action at this time.
0 commit comments