Repository navigation
Description
being able to measure the performance of your application is critical, and some level of automatic instrumentation is imperative to gaining the observability necessary to inspect all layers. this is why tools like tracy are not comparable solutions to this use case as they require manual insertion of all the instrumentation calls. this would tie the instrumentation to tracy and make calls to libraries entirely opaque so its a non-starter. however tracy usage could be used on top of this api.
however, it is also necessary to not simply put instrumentation in every function call in your app because the use cases that would gain the most value from this have core loops that are scoped regions where comparison over time is also usually a common point of analysis: eg web server request handlers, game frame renderer, etc.
non-exhaustive prior art
- gcc/clang
-finstrument-functions - https://docs.python.org/3/library/profile.html
- https://go.dev/blog/pprof
sample code
@profileStart(start, end);
someCall();
@profileStop();@profileStart(
start: *const fn(thread_id: os.pid_t, func_info: std.builtin.SourceLocation) void,
end: *const fn(thread_id: os.pid_t, func_info: std.builtin.SourceLocation) void
) void
@profileEnd() voidmore details:
- this would insert
start(); defer end();calls into the callstack of every function undersomeCall(); startandendmay not error, so as to not interfere with Zig's commitment to no hidden control flow- a
thread_idof0,null, or otherwise invalid value would be passed when the function is called outside the bounds of a@profileStart()/@profileEnd()bounds - being invisible to callees is a direct goal of this proposal
- the added runtime cost of this intervention is a direct goal of this proposal, and accepted by users of this API as the ability to perform the introspection is worth it
Activity
nektro commentedon Apr 27, 2023
digging into
cProfile(python's builtin) it appears to useptrace(2)andperf_event_open(2). I need to research its capabilities more, and will report here.leecannon commentedon Apr 27, 2023
What happens in situations like this:
nektro commentedon Apr 27, 2023
@profileStartcould set some global intmatklad commentedon May 2, 2023
I think this is debatable. Often, sampling, rather than instrumentation, works best if you want to gain visibility into everything. Eg, on Linux
perfis used quite successfully for this, and I think Go CPU profiler is also based on sampling? (at least https://gperftools.github.io/gperftools/cpuprofile.html is).nektro commentedon May 29, 2023
sampling could definitely get me something good and it is an avenue I'm exploring but I opened this issue because my ideal is being able to generate an exact event stream that I can then pass into something like https://github.com/colrdavidson/spall
nektro commentedon Sep 20, 2023
its a bit tedious but i think i've changed my mind on this and prefer manual instrumentation