Giter Site home page Giter Site logo

polarsignals / rust-jemalloc-pprof Goto Github PK

View Code? Open in Web Editor NEW
79.0 5.0 7.0 94 KB

Convert jemalloc heap profiles to pprof to understand memory usage, fix memory leaks, and fix OOM Kills.

License: Apache License 2.0

Rust 96.13% Nix 0.96% C 0.40% Roff 2.51%
continuous-profiling heap jemalloc memory memory-allocation memory-leak memory-leak-detection pprof profiling rust

rust-jemalloc-pprof's People

Contributors

brancz avatar umanwizard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rust-jemalloc-pprof's Issues

Not building on M1 mac

Hey! I'm seeing this on M1 mac:

error[E0432]: unresolved imports `libc::dl_iterate_phdr`, `libc::dl_phdr_info`, `libc::Elf64_Word`, `libc::PT_LOAD`, `libc::PT_NOTE`
  --> /Users/jack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jemalloc_pprof-0.1.0/src/linux.rs:27:20
   |
27 | use libc::{c_void, dl_iterate_phdr, dl_phdr_info, size_t, Elf64_Word, PT_LOAD, PT_NOTE};
   |                    ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^          ^^^^^^^^^^  ^^^^^^^  ^^^^^^^ no `PT_NOTE` in the root
   |                    |                |                     |           |
   |                    |                |                     |           no `PT_LOAD` in the root
   |                    |                |                     no `Elf64_Word` in the root
   |                    |                no `dl_phdr_info` in the root
   |                    no `dl_iterate_phdr` in the root

error[E0609]: no field `p_type` on type `&_`
   --> /Users/jack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jemalloc_pprof-0.1.0/src/linux.rs:225:15
    |
225 |         if ph.p_type == PT_LOAD {
    |               ^^^^^^

Attempt to add with overflow

Describe the bug

There was an overflow in the fetch memory heap file.
image

How to reproduce?

  1. download rust-jemalloc-pprof
    image
  2. build & run
    image

What did you expect to see?

Successfully fetching files from profiling memory

What did you see instead?

reply empty
image
attempt to add with overflow
image

Environment (please complete the following information)

image

Support macOS

Edits from Brennan:

I'm repurposing this issue to "support macOS". The original issue is below.

The main thing we need to do to support macOS is provide something like linux::collect_shared_objects for macOS. This can probably done using the functions documented in dyld(3).


Hi peeps,

I am looking for some guidance on how to run pprof on macos,

I have a rust app configured as follows:

  1. app/Cargo.toml
[profile.release] 
lto = "thin"
debug = 1  # Line tables only.

tikv-jemalloc-ctl = { version = "0.5" }
tikv-jemalloc-sys = { version = "0.5", features = ["profiling"] }
tikv-jemallocator = { version = "0.5", features = ["profiling"] }

[target.'cfg(not(target_os = "macos"))'.dependencies]
jemalloc_pprof = "0.1.0"
  1. conditionally add it to axum
    #[cfg(not(target_os = "macos"))]
    {
        router = router.route("/debug/pprof/heap", get(web::pprof::pprof_heap));
    }
  1. port-forward on the pod

  2. run go tool pprof http://localhost:9200/debug/pprof/heap locally, it throws:

Fetching profile over HTTP from http://localhost:9200/debug/pprof/heap
Local symbolization failed for app (build ID 9d67e10139bad60c021451c99d19ec33b08f8a67): open /usr/local/bin/app: no such file or directory
Local symbolization failed for libpthread.so.0 (build ID 255e355c207aba91a59ae1f808e3b4da443abf0c): open /lib/x86_64-linux-gnu/libpthread.so.0: no such file or directory
Local symbolization failed for libc.so.6 (build ID a3780b0b8a5bf5876e31d16b0a9d8fc6ba69a1f2): open /lib/x86_64-linux-gnu/libc.so.6: no such file or directory
Some binary filenames not available. Symbolization may be incomplete.
Try setting PPROF_BINARY_PATH to the search path for local binaries.
http post http://localhost:9200/debug/pprof/symbol: server response: 404 Not Found

the mechanics of how all this connects is quite hazy for me, but it looks like app binary does not have symbols and that is causing the local symbolization to fail,

question: is that due to #[cfg(not(target_os = "macos"))]? pprof works for the cpu profile, indicating the app binary has the correct symbols *maybe?

btw, for testing, I've copied the binary locally, and open /usr/local/bin/app: no such file or directory was gone, the other two remained

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.