mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Do not build a superflous 'all' postings
This commit is contained in:
parent
6892fc6dcb
commit
f904cd385f
13
compact.go
13
compact.go
|
@ -17,7 +17,6 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -365,10 +364,6 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
|
||||||
}
|
}
|
||||||
c.metrics.ran.Inc()
|
c.metrics.ran.Inc()
|
||||||
c.metrics.duration.Observe(time.Since(t).Seconds())
|
c.metrics.duration.Observe(time.Since(t).Seconds())
|
||||||
|
|
||||||
// We might have done quite a few allocs. Enforce a GC so they do not accumulate
|
|
||||||
// with subsequent compactions or head GCs.
|
|
||||||
runtime.GC()
|
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
|
|
||||||
dir := filepath.Join(dest, meta.ULID.String())
|
dir := filepath.Join(dest, meta.ULID.String())
|
||||||
|
@ -570,14 +565,6 @@ func (c *LeveledCompactor) populateBlock(blocks []BlockReader, meta *BlockMeta,
|
||||||
return errors.Wrap(err, "write postings")
|
return errors.Wrap(err, "write postings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write a postings list containing all series.
|
|
||||||
all := make([]uint64, i)
|
|
||||||
for i := range all {
|
|
||||||
all[i] = uint64(i)
|
|
||||||
}
|
|
||||||
if err := indexw.WritePostings("", "", newListPostings(all)); err != nil {
|
|
||||||
return errors.Wrap(err, "write 'all' postings")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
6
db.go
6
db.go
|
@ -21,6 +21,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -349,9 +350,12 @@ func (db *DB) compact() (changes bool, err error) {
|
||||||
}
|
}
|
||||||
changes = true
|
changes = true
|
||||||
|
|
||||||
|
runtime.GC()
|
||||||
|
|
||||||
if err := db.reload(); err != nil {
|
if err := db.reload(); err != nil {
|
||||||
return changes, errors.Wrap(err, "reload blocks")
|
return changes, errors.Wrap(err, "reload blocks")
|
||||||
}
|
}
|
||||||
|
runtime.GC()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for compactions of multiple blocks.
|
// Check for compactions of multiple blocks.
|
||||||
|
@ -380,10 +384,12 @@ func (db *DB) compact() (changes bool, err error) {
|
||||||
return changes, errors.Wrap(err, "delete compacted block")
|
return changes, errors.Wrap(err, "delete compacted block")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
runtime.GC()
|
||||||
|
|
||||||
if err := db.reload(); err != nil {
|
if err := db.reload(); err != nil {
|
||||||
return changes, errors.Wrap(err, "reload blocks")
|
return changes, errors.Wrap(err, "reload blocks")
|
||||||
}
|
}
|
||||||
|
runtime.GC()
|
||||||
}
|
}
|
||||||
|
|
||||||
return changes, nil
|
return changes, nil
|
||||||
|
|
3
head.go
3
head.go
|
@ -15,7 +15,6 @@ package tsdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -515,8 +514,6 @@ Outer:
|
||||||
|
|
||||||
// gc removes data before the minimum timestmap from the head.
|
// gc removes data before the minimum timestmap from the head.
|
||||||
func (h *Head) gc() {
|
func (h *Head) gc() {
|
||||||
defer runtime.GC()
|
|
||||||
|
|
||||||
// Only data strictly lower than this timestamp must be deleted.
|
// Only data strictly lower than this timestamp must be deleted.
|
||||||
mint := h.MinTime()
|
mint := h.MinTime()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue