jvm-profiling-tools / perf-map-agent

A java agent to generate method mappings to use with the linux `perf` tool
GNU General Public License v2.0
1.65k stars 260 forks source link

Document how to run perf-map-agent against Docker containers #40

Closed sattishv closed 5 years ago

sattishv commented 8 years ago

Hi team,

We have our application running inside a container. If thats the case the map-agent should be installed outside or inside the container. I presume it should be done inside the container because the jdk we use is referenced inside. Could you please review and let us know the ideal approach.

Sattish.

jrudolph commented 7 years ago

@sattishv, this is a good question. There seem to be several issues around running perf-map-agents in containers. The simplest way is probably installing perf-map-agent inside the container and then spawning another shell in the same container and then running the scripts as usual. As others have reported this needs sudo to work inside the container.

A nicer solution would be to be able to run perf and perf-map-agent from outside the container. As far as I have tried that there seem to be several issues around that with PIDs not matching inside and outside the container etc. It would be nice if someone would get this to work. It might be that this feature would need specific support from perf itself.

jrudolph commented 5 years ago

Here's information about how to do that:

Though, afaik, it hasn't been achieved yet to run perf-map-agent outside of the container.

jrudolph commented 5 years ago

I managed to run the attach script from the host namespace. I haven't properly integrated that as it needs some hacking of internals from tools.jar. Right now it will only work if the target process has PID 1 in the container.

See https://github.com/jvm-profiling-tools/perf-map-agent/compare/jr/attach-to-container-from-host

jrudolph commented 5 years ago

Let's close this one as a duplicate of #50.