Skip to content

Commit

Permalink
enable pprof cpu profiling (#5081)
Browse files Browse the repository at this point in the history
* enable pprof cpu profiling

This adds two routes to control pprof
Enable CPU profiling (100hz)
http://localhost:7280/pprof/start
Get the profile as flamegraph
http://localhost:7280/pprof/stop

The routes are behind the `pprof` feature flag

* switch to flamegraph endpoint

add safeguards
add query parameters
keep and return last flamegraph
  • Loading branch information
PSeitz authored Jun 5, 2024
1 parent b57eb12 commit 01571db
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 0 deletions.
144 changes: 144 additions & 0 deletions quickwit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions quickwit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ postcard = { version = "1.0.4", features = [
], default-features = false }
predicates = "3"
prettyplease = "0.2.0"
pprof = { version = "0.13", features = ["flamegraph"] }
proc-macro2 = "1.0.50"
prometheus = { version = "0.13", features = ["process"] }
proptest = "1"
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ quickwit-storage = { workspace = true, features = ["testsuite"] }
[features]
jemalloc = ["dep:tikv-jemalloc-ctl", "dep:tikv-jemallocator"]
ci-test = []
pprof = ["quickwit-serve/pprof"]
openssl-support = ["openssl-probe"]
# Requires to enable tokio unstable via RUSTFLAGS="--cfg tokio_unstable"
tokio-console = ["console-subscriber", "quickwit-common/named_tasks"]
Expand Down
7 changes: 7 additions & 0 deletions quickwit/quickwit-serve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mime_guess = { workspace = true }
once_cell = { workspace = true }
opentelemetry = { workspace = true }
percent-encoding = { workspace = true }
pprof = { workspace = true, optional = true }
prost = { workspace = true }
prost-types = { workspace = true }
regex = { workspace = true }
Expand Down Expand Up @@ -91,3 +92,9 @@ quickwit-opentelemetry = { workspace = true, features = ["testsuite"] }
quickwit-proto = { workspace = true, features = ["testsuite"] }
quickwit-search = { workspace = true, features = ["testsuite"] }
quickwit-storage = { workspace = true, features = ["testsuite"] }

[features]
pprof = [
"dep:pprof"
]

1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mod metrics_api;
mod node_info_handler;
mod openapi;
mod otlp_api;
mod pprof;
mod rate_modulator;
mod rest;
mod rest_api_response;
Expand Down
Loading

0 comments on commit 01571db

Please sign in to comment.