MCPcopy
hub / github.com/prometheus/prometheus / mmapHeadChunks

Method mmapHeadChunks

tsdb/head.go:1972–1996  ·  view source on GitHub ↗

mmapHeadChunks iterates all memSeries stored on Head ready for m-mapping and calls mmapChunks() on each of them. There are two types of chunks that store samples for each memSeries: A) Head chunk - stored on Go heap, when new samples are appended they go there. B) M-mapped chunks - memory mapped ch

()

Source from the content-addressed store, hash-verified

1970// M-mapping is serialised via the per-series lock and done away from the sample append path,
1971// since holding the lock during an append could delay the next scrape or cause query timeouts.
1972func (h *Head) mmapHeadChunks() {
1973 var count int
1974 for i := range h.series.size {
1975 if h.series.mmapReady[i].Load() == 0 {
1976 continue // No series in this stripe need mmapping.
1977 }
1978
1979 h.series.locks[i].RLock()
1980 for _, series := range h.series.series[i] {
1981 if series.headChunkCount.Load() < 2 { // < 2 means 0 or 1 head chunks, nothing to mmap.
1982 continue
1983 }
1984
1985 series.Lock()
1986 n := series.mmapChunks(h.chunkDiskMapper)
1987 series.Unlock()
1988 if n > 0 {
1989 count += n
1990 h.series.decMmapReady(series.ref)
1991 }
1992 }
1993 h.series.locks[i].RUnlock()
1994 }
1995 h.metrics.mmapChunksTotal.Add(float64(count))
1996}
1997
1998// seriesHashmap lets TSDB find a memSeries by its label set, via a 64-bit hash.
1999// There is one map for the common case where the hash value is unique, and a

Calls 5

LockMethod · 0.80
mmapChunksMethod · 0.80
decMmapReadyMethod · 0.80
LoadMethod · 0.65
AddMethod · 0.65