Skip to content

ports/zephyr-cp: enable LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE - #11233

Open
lynt-smitka wants to merge 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-interpreter-opts
Open

ports/zephyr-cp: enable LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE#11233
lynt-smitka wants to merge 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-interpreter-opts

Conversation

@lynt-smitka

Copy link
Copy Markdown

ports/zephyr-cp builds without py/circuitpy_mpconfig.mk, so two interpreter options every other port gets - MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant