FlameGraph icon indicating copy to clipboard operation
FlameGraph copied to clipboard

Add support for jmaps in containers

Open bobrik opened this issue 6 years ago • 2 comments

This is built on the following work:

  • https://github.com/jvm-profiling-tools/perf-map-agent/issues/50
  • http://batey.info/docker-jvm-flamegraphs.html
  • https://github.com/chbatey/perf-map-agent/commit/60c50eb5519355b68bab8a3ddfdf1c9bf67d32f4

Sometimes jrunscript is not included in images. Should we try JAVA_HOME and fall back to jrunscript if it's missing?

Diff is better viewed with whitespace changes ignored. It's not very nice, though.

Here's a flamegraph from a test Logstash instance running in a container:

image

We used flamegraph-perf wrapper, which is essentially this:

/usr/bin/perf record -o perf.data "$@"

/usr/local/flamegraph/jmaps 1>&2

/usr/bin/perf script -i perf.data | /usr/local/flamegraph/stackcollapse-perf.pl --all | c++filt | fgrep -v cpuidle_enter_state | /usr/local/flamegraph/flamegraph.pl --colors=java --hash --title=$(hostname)

cc @chbatey, @alicegoldfuss, @jrudolph

bobrik avatar May 16 '18 05:05 bobrik

@goldshtn I updated it to use nsenter, but it still relies on docker cgroup to detect containers.

Should I remove this assumption and just always call nsenter? I think it may make it universal.

bobrik avatar May 18 '18 04:05 bobrik

I think if it works, there’s no harm in doing it. Unfortunately I don’t see a generic way of definitively confirming that a process is running in a container. For this specific case, all you care about is namespaces though.

On Fri, May 18, 2018 at 07:55 Ivan Babrou [email protected] wrote:

@goldshtn https://github.com/goldshtn I updated it to use nsenter, but it still relies on docker cgroup to detect containers.

Should I remove this assumption and just always call nsenter? I think it may make it universal.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/brendangregg/FlameGraph/pull/171#issuecomment-390094377, or mute the thread https://github.com/notifications/unsubscribe-auth/ABm3vZNC07Bm_krkUCdYvV-NpSspsgB0ks5tzlRZgaJpZM4UApqx .

goldshtn avatar May 18 '18 05:05 goldshtn

Cleaning up old PRs. This would need to be tested on containers in 2023 to make sure it still works.

brendangregg avatar Nov 07 '23 00:11 brendangregg

We do not carry this patch internally and I haven't cared about java in containers for ages, so let's just close it.

bobrik avatar Dec 29 '23 05:12 bobrik

  您好,邮件已收到,我将在上机后,尽快给您回复。

lanseie avatar Dec 29 '23 05:12 lanseie