-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[WIP] Add jl_start_tracking_dispatches / jl_finish_tracking_dispatches #33710
Conversation
Allows users to track all dynamic dispatches that occur when tracking is enabled. This can be useful for debugging purposes, such as to understand where your code has type-instabilities that lead to a dispatch. It will also be used by StagedFunctions.jl to cheaply record the set of MethodInstances that need to have backedges set to the generated function.
I'm a little worried about adding extra instructions in a path that's this hot, even with the unlikely annotation. If it's just for debugging I would have suggested a patch point, but sounds like you're imagining a case where generated functions would turn this on automatically? |
I have to agree it does not seem acceptable to add code to this path. |
Yeah, i had the same concern. :( Thanks for the quick feedback, i was going to ask that same question myself. ❤️ Are there any good alternatives that jump to your mind(s)? |
(I bumped it up to more like 3% - 5% when i added more methods to r, to avoid it somehow inlining and avoiding the dispatch.) |
Usually just something like On my machine, this takes about 11.4 nanoseconds, which is probably about 36 cycles or 650 flops (2.7GHz base frequency, |
replaced by --trace-dispatch |
Allow users to track all dynamic dispatches that occur when tracking is enabled.
This can be useful for debugging, such as to understand where your code has type-instabilities that lead to a dispatch.
It will also be used by StagedFunctions.jl (and ideally base Generated functions) to cheaply record the set of MethodInstances that need to have backedges set to the generated function. Merging this into #32774 should be enough to fix all the tests! :)
There is an example of this working, in the StagedFunctions package, here:
NHDaly/StagedFunctions.jl#9