[GR-71240] Unload and reparse bytecode files #608
Closed
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.
Serialized bytecode for code loaded from pyc files can now be unloaded from memory. Possible later reparsing will be able to fetch it again from the same pyc file, using an offset. To have confidence that we're actually reparsing the right file, I intrinsified a small part of
_bootstrap_external. Only this code path allows unloading. If the pyc file is deleted or changed (detected by comparing the header, which by default is mtime+size), the reparsing fails with aSystemError. The reparsing happens when you use instrumentation (tagged or settrace/monitoring). Aso, the bytecode has to be realoaded when accessingco_codeof a code object that was loaded from a pyc file. Note that this optimization has no effect when running from py files or frozen modules, only pyc files. Locally, I measured a 5% improvement onheap:import-a-lot.