mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Allow mmap to run during head compaction
Signed-off-by: alanprot <alanprot@gmail.com>
This commit is contained in:
parent
b09eaf8acd
commit
e16b7b3449
24
tsdb/db.go
24
tsdb/db.go
|
@ -1057,9 +1057,26 @@ func (db *DB) Dir() string {
|
||||||
|
|
||||||
func (db *DB) run(ctx context.Context) {
|
func (db *DB) run(ctx context.Context) {
|
||||||
defer close(db.donec)
|
defer close(db.donec)
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-db.stopc:
|
||||||
|
return
|
||||||
|
case <-time.After(1 * time.Minute):
|
||||||
|
// We attempt mmapping of head chunks regularly.
|
||||||
|
db.head.mmapHeadChunks()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
backoff := time.Duration(0)
|
backoff := time.Duration(0)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-db.stopc:
|
case <-db.stopc:
|
||||||
|
@ -1079,8 +1096,6 @@ func (db *DB) run(ctx context.Context) {
|
||||||
case db.compactc <- struct{}{}:
|
case db.compactc <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
// We attempt mmapping of head chunks regularly.
|
|
||||||
db.head.mmapHeadChunks()
|
|
||||||
case <-db.compactc:
|
case <-db.compactc:
|
||||||
db.metrics.compactionsTriggered.Inc()
|
db.metrics.compactionsTriggered.Inc()
|
||||||
|
|
||||||
|
@ -1100,6 +1115,9 @@ func (db *DB) run(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appender opens a new appender against the database.
|
// Appender opens a new appender against the database.
|
||||||
|
|
Loading…
Reference in a new issue