Skip to content

Commit 01a38c7

Browse files
authored
Enable continuous memory profiling (#1306)
Adds `jemalloc` feature and enables it by default, which uses the jemalloc allocator and allows us to expose `/debug/pprof/allocs` on the admin endpoint to get `inuse_space` memory profiles, that can be automatically scraped into grafana. Had to move some things around to not collide with the `mimalloc` and `heap-stats` features. I don't know the use-cases and/or status of those features though. On MSVC the `jemalloc` feature should be a no-op since it appears to not be supported.
1 parent db0ec7f commit 01a38c7

File tree

6 files changed

+325
-86
lines changed

6 files changed

+325
-86
lines changed

Cargo.lock

Lines changed: 190 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ codegen-units = 1
4545
lto = "fat"
4646

4747
[features]
48-
default = []
48+
default = ["jemalloc"]
4949
instrument = []
5050
mimalloc = ["dep:mimalloc"]
5151
heap-stats = ["dep:crossbeam-utils"]
52+
jemalloc = ["dep:tikv-jemallocator", "dep:jemalloc_pprof"]
5253

5354

5455
[lints]
@@ -163,6 +164,10 @@ axum = { version = "0.8.4", features = ["macros"] }
163164
version = "0.1"
164165
features = ["client", "client-legacy"]
165166

167+
[target.'cfg(not(target_env = "msvc"))'.dependencies]
168+
jemalloc_pprof = { workspace = true, optional = true }
169+
tikv-jemallocator = { workspace = true, optional = true }
170+
166171
[target.'cfg(target_os = "linux")'.dependencies]
167172
io-uring = { version = "0.7", default-features = false }
168173
libc.workspace = true
@@ -219,6 +224,7 @@ corrosion-utils = { path = "crates/corrosion-utils" }
219224
eyre = "0.6.12"
220225
enum-map = "2.7.3"
221226
futures = "0.3.31"
227+
jemalloc_pprof = { version = "0.8", features = ["symbolize"] }
222228
kube = { version = "1.1", features = [
223229
"runtime",
224230
"rustls-tls",
@@ -243,6 +249,7 @@ serde = { version = "1.0.219", features = ["derive", "rc"] }
243249
serde_json = "1.0.140"
244250
socket2 = { version = "0.6", features = ["all"] }
245251
tempfile = "3.20.0"
252+
tikv-jemallocator = { version = "0.6", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }
246253
time = { version = "0.3", default-features = false, features = ["std"] }
247254
thiserror = "2.0.12"
248255
tokio-stream = { version = "0.1.17", features = ["net", "sync"] }

0 commit comments

Comments
 (0)