Skip to content

Commit

Permalink
Remove gperftools, use jemalloc (#865)
Browse files Browse the repository at this point in the history
* Remove gperftools, use jemalloc

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

* Throw this in

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

* Lint

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

* Remove leftover cruft

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

* Lints

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

* lints part deux

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>

---------

Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>
  • Loading branch information
bleggett authored Apr 3, 2024
1 parent 6559bc9 commit cc89867
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 111 deletions.
169 changes: 134 additions & 35 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rust-version = "1.65"

[features]
default = ["tls-ring"]
gperftools = ["dep:gperftools"]
jemalloc = ["dep:tikv-jemallocator", "dep:jemalloc_pprof"]
console = ["dep:console-subscriber"]
tls-boring = ["dep:boring", "dep:boring-sys", "boring-rustls-provider/fips-only", "ztunnel/tls-boring"]
tls-ring = ["dep:ring", "rustls/ring", "tokio-rustls/ring", "hyper-rustls/ring", "dep:rcgen", "ztunnel/tls-ring"]
Expand Down Expand Up @@ -48,7 +48,8 @@ duration-str = "0.7"
futures = "0.3"
futures-core = "0.3"
futures-util = "0.3"
gperftools = { version = "0.2", features = ["heap"], optional = true }
jemalloc_pprof = { version = "0.1.0", optional = true }
tikv-jemallocator = { version = "0.5.4", features = ["profiling", "unprefixed_malloc_on_supported_platforms"], optional = true }
hashbrown = "0.14"
hickory-client = "0.24"
hickory-proto = "0.24"
Expand Down
48 changes: 48 additions & 0 deletions PROFILING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Profiling ztunnel

## CPU

1. Port-forward admin port (15000):

```sh
k port-forward -n istio-system ztunnel-qkvdj 15000:15000
```

1. Either open `localhost:15000` in a browser for help, or just `curl` the CPU profile:

```sh
curl localhost:15000/debug/pprof/profile > profile.prof
```

1. Observe in your tooling of choice, such as [flamegraph](https://flamegraph.com/)

## Memory

1. Build `ztunnel` with the `jemalloc` feature (disabled by default, see `Cargo.toml`)

1. Port-forward admin port (15000):

```sh
k port-forward -n istio-system ztunnel-qkvdj 15000:15000
```

1. Either open `localhost:15000` in a browser for help, or just `curl` the memory profile:

```sh
curl localhost:15000/debug/pprof/heap > mem.pb.gz
```

1. If working remotely, copy container binaries to local path for symbol resolution:

```sh
# ztunnel main binary
kubectl cp kube-system/ztunnel-qkvdj:/usr/local/bin/ztunnel ../../ztunnel-libs-pprof/ztunnel
# stdlibs (optional)
kubectl cp kube-system/ztunnel-qkvdj:/usr/lib/$BINARY_COMPILED_ARCH/ ../../ztunnel-libs-pprof/
```

1. Observe in your tooling of choice, such as golang's `pprof`:

```sh
PPROF_BINARY_PATH=../../ztunnel-libs-pprof pprof -http=:8080 mem.pb.gz
```
Loading

0 comments on commit cc89867

Please sign in to comment.