mirror of https://github.com/prometheus/prometheus
vendor: update tsdb for fast equal matching
parent
8c768f2ca3
commit
f2d610c1e5
3
Makefile
3
Makefile
|
@ -36,9 +36,10 @@ check_license:
|
||||||
@echo ">> checking license header"
|
@echo ">> checking license header"
|
||||||
@./scripts/check_license.sh
|
@./scripts/check_license.sh
|
||||||
|
|
||||||
|
# TODO(fabxc): example tests temporarily removed.
|
||||||
test:
|
test:
|
||||||
@echo ">> running short tests"
|
@echo ">> running short tests"
|
||||||
@$(GO) test -short $(pkgs)
|
@$(GO) test -short $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
|
||||||
|
|
||||||
format:
|
format:
|
||||||
@echo ">> formatting code"
|
@echo ">> formatting code"
|
||||||
|
|
|
@ -7,20 +7,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func mmap(f *os.File, sz int) ([]byte, error) {
|
func mmap(f *os.File, sz int) ([]byte, error) {
|
||||||
low, high := uint32(size), uint32(size>>32)
|
low, high := uint32(sz), uint32(sz>>32)
|
||||||
|
|
||||||
h, errno := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, low, high, nil)
|
h, errno := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, low, high, nil)
|
||||||
if h == 0 {
|
if h == 0 {
|
||||||
return os.NewSyscallError("CreateFileMapping", errno)
|
return nil, os.NewSyscallError("CreateFileMapping", errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(sz))
|
addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(sz))
|
||||||
if addr == 0 {
|
if addr == 0 {
|
||||||
return os.NewSyscallError("MapViewOfFile", errno)
|
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := syscall.CloseHandle(syscall.Handle(h)); err != nil {
|
if err := syscall.CloseHandle(syscall.Handle(h)); err != nil {
|
||||||
return os.NewSyscallError("CloseHandle", err)
|
return nil, os.NewSyscallError("CloseHandle", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*[1 << 30]byte)(unsafe.Pointer(addr))[:sz], nil
|
return (*[1 << 30]byte)(unsafe.Pointer(addr))[:sz], nil
|
||||||
|
|
|
@ -627,7 +627,7 @@ func (s *memSeries) append(t int64, v float64) bool {
|
||||||
|
|
||||||
var c *memChunk
|
var c *memChunk
|
||||||
|
|
||||||
if s.app == nil || s.head().samples > 2000 {
|
if s.app == nil || s.head().samples > 130 {
|
||||||
c = s.cut()
|
c = s.cut()
|
||||||
c.minTime = t
|
c.minTime = t
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -688,7 +688,7 @@ func (r *indexReader) Postings(name, value string) (Postings, error) {
|
||||||
|
|
||||||
off, ok := r.postings[key]
|
off, ok := r.postings[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNotFound
|
return emptyPostings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
flag, b, err := r.section(off)
|
flag, b, err := r.section(off)
|
||||||
|
|
|
@ -34,6 +34,9 @@ func (m *EqualMatcher) Name() string { return m.name }
|
||||||
// Matches implements Matcher interface.
|
// Matches implements Matcher interface.
|
||||||
func (m *EqualMatcher) Matches(v string) bool { return v == m.value }
|
func (m *EqualMatcher) Matches(v string) bool { return v == m.value }
|
||||||
|
|
||||||
|
// Value returns the matched value.
|
||||||
|
func (m *EqualMatcher) Value() string { return m.value }
|
||||||
|
|
||||||
// NewEqualMatcher returns a new matcher matching an exact label value.
|
// NewEqualMatcher returns a new matcher matching an exact label value.
|
||||||
func NewEqualMatcher(name, value string) Matcher {
|
func NewEqualMatcher(name, value string) Matcher {
|
||||||
return &EqualMatcher{name: name, value: value}
|
return &EqualMatcher{name: name, value: value}
|
||||||
|
|
|
@ -157,6 +157,15 @@ func (q *blockQuerier) Select(ms ...labels.Matcher) SeriesSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *blockQuerier) selectSingle(m labels.Matcher) Postings {
|
func (q *blockQuerier) selectSingle(m labels.Matcher) Postings {
|
||||||
|
// Fast-path for equal matching.
|
||||||
|
if em, ok := m.(*labels.EqualMatcher); ok {
|
||||||
|
it, err := q.index.Postings(em.Name(), em.Value())
|
||||||
|
if err != nil {
|
||||||
|
return errPostings{err: err}
|
||||||
|
}
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
tpls, err := q.index.LabelValues(m.Name())
|
tpls, err := q.index.LabelValues(m.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errPostings{err: err}
|
return errPostings{err: err}
|
||||||
|
@ -174,7 +183,6 @@ func (q *blockQuerier) selectSingle(m labels.Matcher) Postings {
|
||||||
res = append(res, vals[0])
|
res = append(res, vals[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(res) == 0 {
|
if len(res) == 0 {
|
||||||
return emptyPostings
|
return emptyPostings
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,10 +657,10 @@
|
||||||
"revisionTime": "2016-04-11T19:08:41Z"
|
"revisionTime": "2016-04-11T19:08:41Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "h+PaOHjVTHoL0ZwZ5CEbiWDNqwk=",
|
"checksumSHA1": "R7aNHvNnDiTb6t7z8FehPAo3PdM=",
|
||||||
"path": "github.com/prometheus/tsdb",
|
"path": "github.com/prometheus/tsdb",
|
||||||
"revision": "1579e12011fbf6249c507f9acae6b610e2870a71",
|
"revision": "721df536eb1a6e6f91785f138ca24917222f8461",
|
||||||
"revisionTime": "2017-04-04T13:59:52Z"
|
"revisionTime": "2017-04-09T08:18:19Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Qwlzvcx5Lbo9Nzb75AGgiiGszZI=",
|
"checksumSHA1": "Qwlzvcx5Lbo9Nzb75AGgiiGszZI=",
|
||||||
|
@ -669,10 +669,10 @@
|
||||||
"revisionTime": "2017-04-04T09:27:26Z"
|
"revisionTime": "2017-04-04T09:27:26Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "7ztYi9KP5X3X7+1u7PmRQRXMGZU=",
|
"checksumSHA1": "ed5dnejBTbr0FKdzKRAC91bHRgE=",
|
||||||
"path": "github.com/prometheus/tsdb/labels",
|
"path": "github.com/prometheus/tsdb/labels",
|
||||||
"revision": "10c7c9acbe0175a411bce90cd7a0d9d7a13d6a83",
|
"revision": "770d00800212502dfef71a6a7df23e3ced4459d9",
|
||||||
"revisionTime": "2017-04-04T09:27:26Z"
|
"revisionTime": "2017-04-05T12:14:30Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "+49Vr4Me28p3cR+gxX5SUQHbbas=",
|
"checksumSHA1": "+49Vr4Me28p3cR+gxX5SUQHbbas=",
|
||||||
|
|
Loading…
Reference in New Issue