-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add per-PyCodeObject interpreter instruction counter
Summary: Adds a mode to Cinder which disables JIT and then counts how many bytecodes are executed in the interpreter loop per-`PyCodeObject`. This has to be per-`PyCodeObject` as we do not always have access to a `PyFunctionObject` in the interpreter loop. The goal is to maybe build a JIT-list from this and get some insight where the interpreter spends its time. Data can be retrieved using `cinder.get_and_clear_code_interp_count()`, which as the name implies also clears the data. This allows us to accumulate data over multiple calls without worrying about duplicate attribution. I've identified the `PyCodeObject`s with a string of the form `<name|qualname>@<file>:<lineno>`. This is not perfect, for example it's not unique for code generated on the fly (you'll see these with the form `...@<string>:1`). It should be good-enough for a JIT-list though. A side-effect of encoding code identifiers using file + line number means it's now MUCH easier to find where most code actually comes from. Technical notes: * The architecture is a bit weird, with most of the code living in `pyjit.cpp`, but the Python function being exposed in `cinder.c`. The reason for this is I want the simplicity of using C++ data structures to store the data, but with cycle counting enabled JIT is disabled so the API can't be in `cinderjit`. * I hope the changes in `ceval.c` are as light-weight as possible. I can't really measure this without something like Swayze though. Thanks to advice from DinoV the cost should be quite well hidden. * I have not tried to optimize anything outside of `ceval.c` as everything will be running slower anyway with this mode enabled. Reviewed By: DinoV Differential Revision: D26783332 fbshipit-source-id: 25fe116
- Loading branch information
1 parent
ca5d308
commit 0764b2e
Showing
5 changed files
with
132 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters