Skip to content

Time based downsampling during compaction #2880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f20a5d3
Add basic time based downsampling to compactor
aleks-p Dec 21, 2023
bc4cfab
Add histogram metrics for downsampled profile samples
aleks-p Dec 27, 2023
322a192
Use millis for downsampled profile timestamps
aleks-p Dec 27, 2023
fa7e340
Improve constant name
aleks-p Dec 27, 2023
682fbf2
Switch to 5 minutes for the lowest downsampling resolution
aleks-p Dec 27, 2023
711d647
Fix stacktrace IDs in parquet output
aleks-p Dec 27, 2023
3dc9471
Simple support for alternative aggregations
aleks-p Dec 27, 2023
6940903
Add a simple test for downsampling
aleks-p Dec 27, 2023
0acbd67
Remove uuid from downsampled profiles, reduce allocations
aleks-p Dec 28, 2023
709d1b9
Add a benchmark for downsampling
aleks-p Dec 28, 2023
270757e
Switch downsampling to use swiss.Map
aleks-p Dec 28, 2023
b20aede
Switch to TimeNanos for downsampled profiles
aleks-p Dec 28, 2023
22db124
Add swiss map dependency properly
aleks-p Dec 28, 2023
5a3f3e1
Add support for multiple aggregation types as a poc
aleks-p Dec 28, 2023
cef68dd
Remove avg aggregation from downsampler
aleks-p Dec 29, 2023
75c6766
Only initialize downsampler when compaction level > 2
aleks-p Dec 29, 2023
3b46e7d
Remove duration from downsampled profiles
aleks-p Dec 29, 2023
61fe247
Switch to TimeNanos for downsampled profiles
aleks-p Dec 29, 2023
e73a94c
Add downsampling aggregation test
aleks-p Dec 29, 2023
f1e6d45
Add downsampling fingerprint test
aleks-p Dec 29, 2023
386284a
Merge remote-tracking branch 'origin/main' into feat/downsampler
aleks-p Jan 5, 2024
8a590b0
Add global and per-tenant downsampling config
aleks-p Jan 5, 2024
4e6d47c
Add logging, minor refactoring to simplify dependencies
aleks-p Jan 5, 2024
2caeca3
feat: use downsampled data in profile queries (#2881)
kolesnikovae Jan 8, 2024
8deaef4
Merge branch 'main' into feat/downsampler
kolesnikovae Jan 8, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/profilecli/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ func compact(ctx context.Context, src, dst string, metas []*block.Meta, shards i
s.Suffix = " Compacting data..."
s.Restart()

out, err := phlaredb.CompactWithSplitting(ctx, blocks, uint64(shards), 0, dst, phlaredb.SplitByFingerprint)
out, err := phlaredb.CompactWithSplitting(ctx, phlaredb.CompactWithSplittingOpts{
Src: blocks,
Dst: dst,
SplitCount: uint64(shards),
StageSize: 0,
SplitBy: phlaredb.SplitByFingerprint,
DownsamplerEnabled: true,
Logger: logger,
})
if err != nil {
s.Stop()
return err
Expand Down
4 changes: 4 additions & 0 deletions cmd/pyroscope/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Usage of ./pyroscope:
How many times to retry a failed compaction within a single compaction run. (default 3)
-compactor.compaction-split-by string
Experimental: The strategy to use when splitting blocks during compaction. Supported values are: fingerprint, stacktracePartition. (default "fingerprint")
-compactor.compactor-downsampler-enabled
If enabled, the compactor will downsample profiles in blocks at compaction level 3 and above. The original profiles are also kept. (default true)
-compactor.compactor-tenant-shard-size int
Max number of compactors that can compact blocks for single tenant. 0 to disable the limit and use all compactors.
-compactor.data-dir string
Expand All @@ -43,6 +45,8 @@ Usage of ./pyroscope:
Time before a block marked for deletion is deleted from bucket. If not 0, blocks will be marked for deletion and compactor component will permanently delete blocks marked for deletion from the bucket. If 0, blocks will be deleted straight away. Note that deleting blocks immediately can cause query failures. (default 12h0m0s)
-compactor.disabled-tenants comma-separated-list-of-strings
Comma separated list of tenants that cannot be compacted by this compactor. If specified, and compactor would normally pick given tenant for compaction (via -compactor.enabled-tenants or sharding), it will be ignored instead.
-compactor.downsampler-enabled
If enabled, the compactor will downsample profiles in blocks at compaction level 3 and above. The original profiles are also kept.
-compactor.enabled-tenants comma-separated-list-of-strings
Comma separated list of tenants that can be compacted. If specified, only these tenants will be compacted by compactor, otherwise all tenants can be compacted. Subject to sharding.
-compactor.first-level-compaction-wait-period duration
Expand Down
2 changes: 2 additions & 0 deletions cmd/pyroscope/help.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Usage of ./pyroscope:
Directory to store synchronized pyroscope block headers. This directory is not required to be persisted between restarts, but it's highly recommended in order to improve the store-gateway startup time. (default "./data/pyroscope-sync/")
-compactor.blocks-retention-period duration
Delete blocks containing samples older than the specified retention period. 0 to disable.
-compactor.compactor-downsampler-enabled
If enabled, the compactor will downsample profiles in blocks at compaction level 3 and above. The original profiles are also kept. (default true)
-compactor.compactor-tenant-shard-size int
Max number of compactors that can compact blocks for single tenant. 0 to disable the limit and use all compactors.
-compactor.data-dir string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,11 @@ The `compactor` block configures the compactor.
# CLI flag: -compactor.no-blocks-file-cleanup-enabled
[no_blocks_file_cleanup_enabled: <boolean> | default = false]

# If enabled, the compactor will downsample profiles in blocks at compaction
# level 3 and above. The original profiles are also kept.
# CLI flag: -compactor.downsampler-enabled
[downsampler_enabled: <boolean> | default = false]

# Number of goroutines opening blocks before compaction.
# CLI flag: -compactor.max-opening-blocks-concurrency
[max_opening_blocks_concurrency: <int> | default = 16]
Expand Down Expand Up @@ -1925,6 +1930,11 @@ The `limits` block configures default and per-tenant limits imposed by component
# CLI flag: -compactor.partial-block-deletion-delay
[compactor_partial_block_deletion_delay: <duration> | default = 1d]

# If enabled, the compactor will downsample profiles in blocks at compaction
# level 3 and above. The original profiles are also kept.
# CLI flag: -compactor.compactor-downsampler-enabled
[compactor_downsampler_enabled: <boolean> | default = false]

# S3 server-side encryption type. Required to enable server-side encryption
# overrides for a specific tenant. If not set, the default S3 client settings
# are used.
Expand Down
3 changes: 2 additions & 1 deletion ebpf/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.44.0
github.com/prometheus/prometheus v0.48.1
github.com/samber/lo v1.38.1
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
Expand All @@ -27,8 +28,8 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
Expand Down
4 changes: 4 additions & 0 deletions ebpf/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/grafana/pyroscope/api v0.2.0 h1:TzOxL0s6SiaLEy944ZAKgHcx/JDRJXu4O8ObwkqR6p4=
github.com/grafana/pyroscope/api v0.2.0/go.mod h1:nhH+xai9cYFgs6lMy/+L0pKj0d5yCMwji/QAiQFCP+U=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab h1:BA4a7pe6ZTd9F8kXETBoijjFJ/ntaa//1wiH9BZu4zU=
Expand All @@ -54,6 +56,8 @@ github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdO
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/prometheus/prometheus v0.48.1 h1:CTszphSNTXkuCG6O0IfpKdHcJkvvnAAE1GbELKS+NFk=
github.com/prometheus/prometheus v0.48.1/go.mod h1:SRw624aMAxTfryAcP8rOjg4S/sHHaetx2lyJJ2nM83g=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/colega/zeropool v0.0.0-20230505084239-6fb4a4f75381
github.com/dennwc/varint v1.0.0
github.com/dgryski/go-groupvarint v0.0.0-20230630160417-2bfb7969fb3c
github.com/dolthub/swiss v0.2.1
github.com/drone/envsubst v1.0.3
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.15.0
Expand Down Expand Up @@ -112,6 +113,7 @@ require (
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dolthub/maphash v0.1.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/efficientgo/core v1.0.0-rc.2 // indirect
github.com/efficientgo/e2e v0.14.1-0.20230710114240-c316eb95ae5b // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3
github.com/docker/docker v24.0.6+incompatible h1:hceabKCtUgDqPu+qm0NgsaXf28Ljf4/pWFL7xjWWDgE=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ=
github.com/dolthub/maphash v0.1.0/go.mod h1:gkg4Ch4CdCDu5h6PMriVLawB7koZ+5ijb9puGMV50a4=
github.com/dolthub/swiss v0.2.1 h1:gs2osYs5SJkAaH5/ggVJqXQxRXtWshF6uE0lgR/Y3Gw=
github.com/dolthub/swiss v0.2.1/go.mod h1:8AhKZZ1HK7g18j7v7k6c5cYIGEZJcPn0ARsai8cUrh0=
github.com/drone/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
Expand Down
Loading