Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for USDT probes #41685

Merged
merged 2 commits into from
Jul 29, 2021
Merged

Add support for USDT probes #41685

merged 2 commits into from
Jul 29, 2021

Conversation

vchuravy
Copy link
Member

@vchuravy vchuravy commented Jul 23, 2021

Based on a previous exploration with @NHDaly in #31616, this PR adds a infrastructure support for USDT,
supporting dtrace on MacOS and bpftrace and related tools on Linux. Support is gate by a new Make flag.

As an example I added some GC probes that allow one to measure GC latencies, as an example in #41616 I was interested
in the latency distribution of stop-the-world, e.g. how long it takes until GC starts with productive work.

I hope this can provide visibilty into issues like #41586 and #33097

Inspired by https://docs.python.org/3/howto/instrumentation.html

@vchuravy
Copy link
Member Author

@jpsamaroo might be a cool example for BPFnative.jl?

@vchuravy vchuravy requested a review from vtjnash July 23, 2021 14:14
@vchuravy vchuravy marked this pull request as ready for review July 23, 2021 19:33
@Sacha0
Copy link
Member

Sacha0 commented Jul 24, 2021

Exciting! Thanks Valentin! :)

@NHDaly
Copy link
Member

NHDaly commented Jul 25, 2021

Yeah agreed, thanks for picking this up again, Valentin!!

@vchuravy vchuravy force-pushed the vc/gc_probes branch 3 times, most recently from f8a7c55 to 0ea50d7 Compare July 27, 2021 21:36
@jpsamaroo
Copy link
Member

These are working on Linux (musl) with bpftrace and BPFnative!

contrib/bpftrace/gc_all.bt Outdated Show resolved Hide resolved
doc/src/devdocs/probes.md Outdated Show resolved Hide resolved
doc/src/devdocs/probes.md Outdated Show resolved Hide resolved
doc/src/devdocs/probes.md Outdated Show resolved Hide resolved
Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks terrific! Thanks Valentin! :)

@jpsamaroo
Copy link
Member

Any chance we could also get probes on task switching? This could be a good, temporary alternative to #39994, where hook execution can be disabled via Preferences or some other mechanism per-package.

@vchuravy
Copy link
Member Author

For Julia code side probes there is https://github.com/JuliaPerf/UProbes.jl, but that is hamstrung by the lack of JIT support in tools bpftrace/bpftrace#425

@vchuravy
Copy link
Member Author

Any chance we could also get probes on task switching

I think adding probes on task switching shouldn't be too hard.

One thing I haven't tested in a while is ustack support e.g. if we get a correctly demangled stacktraces inside the probe.

This could be a good, temporary alternative to #39994, where hook execution can be disabled via Preferences or some other mechanism per-package.

Uhm... I don't quite understand what you are thinking about, but let's not go down the path of using eBPF programs to modify user-space on task-switches.

@vchuravy vchuravy merged commit fa30e64 into master Jul 29, 2021
@vchuravy vchuravy deleted the vc/gc_probes branch July 29, 2021 11:37
@jpsamaroo
Copy link
Member

Uhm... I don't quite understand what you are thinking about, but let's not go down the path of using eBPF programs to modify user-space on task-switches.

I'm thinking of using it to collect metrics about executing tasks, like being able to calculate the actual CPU execution time of a task (since clock_gettimeis per-thread, we need to exclude other concurrently executing tasks).

@vchuravy
Copy link
Member Author

Wanna give it a go to try adding probes for that?

@carlocab
Copy link
Contributor

carlocab commented Sep 7, 2021

By the way, building from master with WITH_DTRACE=1 fails for me on macOS with the error

 dtrace -h -s /private/tmp/julia-20210907-69372-bfig8y/src/uprobes.d -o uprobes.h.gen
dtrace: failed to compile script /private/tmp/julia-20210907-69372-bfig8y/src/uprobes.d: line 5: syntax error near "probe"
make[2]: *** [uprobes.h.gen] Error 1

I guess uprobes.d needs to be slightly different for macOS dtrace. Apologies for digging up this PR to post this, but I wasn't sure if this was worth tracking in a separate issue. Happy to open a new one if it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants