Skip to content

Add support for USDT probes#41685

Merged
vchuravy merged 2 commits into
masterfrom
vc/gc_probes
Jul 29, 2021
Merged

Add support for USDT probes#41685
vchuravy merged 2 commits into
masterfrom
vc/gc_probes

Conversation

@vchuravy

@vchuravy vchuravy commented Jul 23, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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

Sacha0 commented Jul 24, 2021

Copy link
Copy Markdown
Member

Exciting! Thanks Valentin! :)

@NHDaly

NHDaly commented Jul 25, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

Comment thread contrib/bpftrace/gc_all.bt
Comment thread contrib/bpftrace/gc_all.bt Outdated
Comment thread doc/src/devdocs/probes.md Outdated
Comment thread doc/src/devdocs/probes.md Outdated
Comment thread doc/src/devdocs/probes.md
Comment thread doc/src/devdocs/probes.md
Comment thread doc/src/devdocs/probes.md
Comment thread doc/src/devdocs/probes.md
Comment thread doc/src/devdocs/probes.md Outdated

@Sacha0 Sacha0 left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@carlocab

carlocab commented Sep 7, 2021

Copy link
Copy Markdown
Contributor

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