bnjbvr opened PR #6030 from perf-map
to main
:
This adds support for a simpler way to profile with
perf
, using perf maps files. Whilejitdump
support is pretty effective and complete when you have access to DWARF metadata, theperf-inject
step may take lots of time, and it is not optimized at all when modules contain lots of functions. (In our embedding, I've stoppedperf-inject
after it ran for 5 hours and didn't complete, while creating 175K.so
objects.) Simplistic support for perf maps enable basic profiling: caller/callee trees, top/bottom time analysis, flamegraphs etc., and works very nicely when the wasm modules have many functions.I've also tweaked the documentation and tried to make the feature available in the C API too.
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr edited PR #6030 from perf-map
to main
:
This adds support for a simpler way to profile with
perf
, using perf maps files. Whilejitdump
support is pretty effective and complete when you have access to DWARF metadata, theperf-inject
step may take lots of time, and it is not optimized at all when modules contain lots of functions. (In our embedding, I've stoppedperf-inject
after it ran for 5 hours and didn't complete, while creating 175K.so
objects.) Simplistic support for perf maps enable basic profiling: caller/callee trees, top/bottom time analysis, flamegraphs etc., and works very nicely when the wasm modules have many functions.I've also tweaked the documentation and tried to make the feature available in the C API too.
I haven't put this behind a feature toggle because this profiling agent does very little, so it's always compiled _when running Linux_. For consistency I could add one, if you prefer.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Given the text-based format of this file I think this may need to do some more sanitization of the
name
since any utf-8 sequence is allowed in wasm modules. For example I suspect a function with a newline in the name might cause issues here?
alexcrichton created PR review comment:
Given the text-based format of this file and the multiple writes done here, this might be a good case for using
BufWriter
to write out all this data and then using aflush()
to finish it when the whole module has been written.
alexcrichton created PR review comment:
We may be getting somewhat close to the limit of "now it's probably better to have
--profile=jitdump
" as opposed to a separate flag-per-strategy, but that's fine to defer to a different PR.
bnjbvr submitted PR review.
bnjbvr created PR review comment:
Good point; I've sanitized by removing
\n
and\r
, not sure if there's any other control character I should be worried about?
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr updated PR #6030 from perf-map
to main
.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Ah I missed this earlier, but I think we'll want ot do something other than ignoring errors here ideally. If an error happens it should probably "close" the file and terminate all future writing to it I suspect? (along with perhaps a warning message printed?)
alexcrichton created PR review comment:
I think this may want a flush at the end too?
Also with a
BufWriter
I think you could pass that intomake_line
to avoid the intermediate string allocation (e.g. write directly to the buffer). Although not required of course, that's ok to defer to if it's ever actually an issue.
bnjbvr submitted PR review.
bnjbvr created PR review comment:
Good point! I've added log messages and early-returns. Looks like a
BufWriter
will automatically flush in its Drop impl, so we can avoid doing it explicitly in most early-returns.
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr submitted PR review.
bnjbvr created PR review comment:
Turns out
File
is also aWrite
implementator, so could havemake_line
take&mut dyn Write
and use it here without having aBufWriter
(since there's only one write in this function, it didn't seem worth having an extra buffer).
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #6030.
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr updated PR #6030 from perf-map
to main
.
bnjbvr has enabled auto merge for PR #6030.
bnjbvr merged PR #6030.
Last updated: Nov 22 2024 at 16:03 UTC