Speed up --gil by skipping work for non-GIL threads #630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the user has specified --gil we needn't collect stack traces for the non-GIL threads. This is a significant speedup on heavily threaded Python code.
My server has 271 threads (most of which are idle).
With the previous code (sampling at 10Hz) I get:
With this commit I can sample at 80Hz, and the error rate is way lower:
I suspect the difference in error rate is due to the error handling in
_get_stack_traces
- an error getting information about any thread means that all the traces are thrown away.