Skip to content

Commit

Permalink
Release cpu during compactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilder committed Feb 1, 2017
1 parent 278c144 commit 784a851
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tsdb/engine/tsm1/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,10 @@ func (k *tsmKeyIterator) combine(dedup bool) blocks {
}

k.mergedValues = k.mergedValues.Merge(v)

// Allow other goroutines to run
runtime.Gosched()

}
k.blocks = k.blocks[1:]
}
Expand All @@ -1144,6 +1148,7 @@ func (k *tsmKeyIterator) combine(dedup bool) blocks {
var i int

for i < len(k.blocks) {

// skip this block if it's values were already read
if k.blocks[i].read() {
i++
Expand All @@ -1156,6 +1161,8 @@ func (k *tsmKeyIterator) combine(dedup bool) blocks {
break
}
i++
// Allow other goroutines to run
runtime.Gosched()
}

if k.fast {
Expand All @@ -1168,6 +1175,8 @@ func (k *tsmKeyIterator) combine(dedup bool) blocks {

chunked = append(chunked, k.blocks[i])
i++
// Allow other goroutines to run
runtime.Gosched()
}
}

Expand Down Expand Up @@ -1202,6 +1211,8 @@ func (k *tsmKeyIterator) combine(dedup bool) blocks {

k.mergedValues = k.mergedValues.Merge(v)
i++
// Allow other goroutines to run
runtime.Gosched()
}

k.blocks = k.blocks[i:]
Expand Down

0 comments on commit 784a851

Please sign in to comment.