ports/zephyr-cp: enable LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE - #11233
Open
lynt-smitka wants to merge 1 commit into
Open
ports/zephyr-cp: enable LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE#11233lynt-smitka wants to merge 1 commit into
lynt-smitka wants to merge 1 commit into
Conversation
The make-based ports get these two interpreter options from py/circuitpy_mpconfig.mk: LOAD_ATTR_FAST_PATH defaults to 1 and MAP_LOOKUP_CACHE to CIRCUITPY_FULL_BUILD. The zephyr-cp port does not include that makefile, so neither macro was ever defined - and py/vm.c and py/map.c test them with #if, where an undefined identifier is 0. Both optimizations were therefore silently off on this port. Define them in build_circuitpython.py next to the other interpreter flags, with the same values the classic ports use. Measured on RP2350 (Fruit Jam): method and attribute access microbenchmarks improve about 25%, closing most of the interpreter gap against ports/raspberrypi.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ports/zephyr-cp builds without
py/circuitpy_mpconfig.mk, so two interpreter options every other port gets -MICROPY_OPT_LOAD_ATTR_FAST_PATHandMICROPY_OPT_MAP_LOOKUP_CACHE- are never defined and silently default to off.This defines them in build_circuitpython.py with the same values the other ports use (fast path always on, map lookup cache on full builds).
Measured on an RP2040 (PicoPad), same firmware otherwise: method call + attribute store 26.68 us -> 22.72 us (-15 %), a bytearray(64) loop -14 % (its LOAD_GLOBAL hits the map cache), 32 moving sprites 39.0 -> 42.4 fps. Costs +144B flash and +128B RAM.