Use member non-pointer declarations in Py*State structs instead of heap-allocated pointers. #177
Replies: 6 comments
-
As a passing comment: a large majority of MicroPython's data structures are statically defined, and even const so they can be put directly in the text section (and usually that is physical ROM). This helps immensely with both fast start up time and minimal RAM usage. |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Related: python/cpython#29274 |
Beta Was this translation helpful? Give feedback.
-
@markshannon, I'd like your thoughts on the approach I'm considering for this. It also ties into the discussions we've had on how to deal with all our static variables. You can see the change for my branch here: python/cpython@main...ericsnowcurrently:per-interpreter-globals There are several things that I've tried out:
For most of those, each maps to a single commit, so it may be useful to look at the commits separately. |
Beta Was this translation helpful? Give feedback.
-
FYI, I've been working on eliminating So there may be extra speedup from this that I wasn't expecting. 🙂 |
Beta Was this translation helpful? Give feedback.
-
The full runtime state of a cpython process is found in
PyRuntimeState
,PyInterpreterState, and
PyThreadState(and, for now, a bunch of static variables), which currently form a single tree at runtime under the
_PyRuntime` global variable. Currently these three structs hold many pointers, which are (allocated and) populated during runtime initialization.For most of the pointers we could instead replace them with static declarations (of the the corresponding data) in the relevant
Py*State
structs. (This wouldn't work for any variables where the size isn't fixed at compile time (e.g.PyVarObject
) but it should work for most.)Benefits
(Work being done via #176.)
Beta Was this translation helpful? Give feedback.
All reactions