Feature or enhancement
I would like to add an external flag to the _PyInterpreterFrame struct. This would be a single bit, bit-packed into the same uint8_t that the currently unused visited flag is already occupying.
When anything besides the VM pushes a frame onto the frame stack (for example, anyone using the long-blessed PEP 523 evaluators or writing JITs), oftentimes there is metadata associated with those frames that needs correlation. In order to make that correlation, we need to know if a frame is associated with an external source. There are a couple of ways to solve this, but every solution that doesn't involve storing something on the frame itself involves maintaining a separate data structure and mutating it on every activation. This becomes especially difficult when dealing with arbitrary frames, for example from the perspective of either GC or a profiler/debugger.
The ideal solution involves having a bit on the interpreter frame that indicates it's safe to read some other data structure containing the metadata. For example, we could stack allocate the metadata immediately before the interpreter frame, and this bit proves it's safe to read.
This should have zero impact on memory, since it's using an existing bit. It should also have zero impact on performance until the point that the visited flag is actually used, at which point it should be negligible since it will be one additional mask.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
cc @DinoV @markshannon
Linked PRs
Feature or enhancement
I would like to add an
externalflag to the _PyInterpreterFrame struct. This would be a single bit, bit-packed into the same uint8_t that the currently unusedvisitedflag is already occupying.When anything besides the VM pushes a frame onto the frame stack (for example, anyone using the long-blessed PEP 523 evaluators or writing JITs), oftentimes there is metadata associated with those frames that needs correlation. In order to make that correlation, we need to know if a frame is associated with an external source. There are a couple of ways to solve this, but every solution that doesn't involve storing something on the frame itself involves maintaining a separate data structure and mutating it on every activation. This becomes especially difficult when dealing with arbitrary frames, for example from the perspective of either GC or a profiler/debugger.
The ideal solution involves having a bit on the interpreter frame that indicates it's safe to read some other data structure containing the metadata. For example, we could stack allocate the metadata immediately before the interpreter frame, and this bit proves it's safe to read.
This should have zero impact on memory, since it's using an existing bit. It should also have zero impact on performance until the point that the
visitedflag is actually used, at which point it should be negligible since it will be one additional mask.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
cc @DinoV @markshannon
Linked PRs