Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/20.07- Rollup: Reduce memory consumption of the map (#5599) #5957

Merged
merged 2 commits into from
Jul 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions posting/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,22 @@ func (ir *incrRollupi) Process(closer *y.Closer) {

m := make(map[uint64]int64) // map hash(key) to ts. hash(key) to limit the size of the map.
limiter := time.NewTicker(100 * time.Millisecond)
defer limiter.Stop()
cleanupTick := time.NewTicker(5 * time.Minute)
defer cleanupTick.Stop()

for {
select {
case <-closer.HasBeenClosed():
return
case <-cleanupTick.C:
currTs := time.Now().UnixNano()
for hash, ts := range m {
// Remove entries from map which have been there for there more than 10 seconds.
if currTs-ts >= int64(10*time.Second) {
delete(m, hash)
}
}
case batch := <-ir.keysCh:
currTs := time.Now().Unix()
for _, key := range *batch {
Expand Down