-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Unify handling of stats in the CPython VM #90230
Comments
By "stats" I mean the internal numbers gathered by the VM for performance and debugging. This has nothing to do with any statistics module. Currently various parts of the VM gather stats: the GC, dicts, the bytecode interpreter, type lookup cache, etc. These stats have various compile time flags to turn them on and off. They have differing ways to display the stats, and no unified way to gather stats across different runs. For the specialization stats we dump stats, which we can parse to collate stats across runs. We should:
|
Could you please add the new option to Doc/using/configure.rst ? |
I just noticed that you are using hard-coded paths with /tmp for the pystats directory. That's problematic and opens the possibility of a symlink race attack. Could please add exclusive create to _Py_PrintSpecializationStats()? The will prevent symlink attacks. fopen() mode "x" is not generally available in all libcs. You have to combine open() and fdopen(): int flags = O_WRONLY | O_CREAT | O_EXCL;
#ifdef O_NOFOLLOW
flags |= O_NOFOLLOW;
#endif
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
int fd = open(path, flags);
if (fd >= 0) {
FILE *fout = fdopen(fd, "w");
} |
The --enable-stats option is for CPython development and shouldn't be turned on for a release version, so I'm not really concerned about people attacking their own machines. |
Python API should be provided? This allows us to have more accurate statistical information about the status. For example, in pyperformance import _opcode as stats
def main(loops, level):
...
...
stats.init_specialization_stats() # Clear unrelated status information
stats.enable_specialization_stats()
for _ in range_it: # core loop of benchmark
stream = io.StringIO()
solve_file(board, strategy, order, stream)
output = stream.getvalue()
stream = None
stats.disable_specialization_stats()
print(stats.get_specialization_stats())# Print status information
...
...
return dt Then get stats dict:
This helps us to more precisely analyze the impact of optimization on benchmark. |
The stats seem to working well, so I'm closing this. |
BINARY_OP
#31289Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: