-
- Downloads
py: Improve allocation policy of qstr data.
Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
Showing
- py/gc.c 6 additions, 1 deletionpy/gc.c
- py/gc.h 1 addition, 1 deletionpy/gc.h
- py/malloc.c 7 additions, 4 deletionspy/malloc.c
- py/misc.h 4 additions, 4 deletionspy/misc.h
- py/mpconfig.h 8 additions, 0 deletionspy/mpconfig.h
- py/mpstate.h 6 additions, 0 deletionspy/mpstate.h
- py/objexcept.c 1 addition, 1 deletionpy/objexcept.c
- py/parse.c 2 additions, 2 deletionspy/parse.c
- py/qstr.c 40 additions, 1 deletionpy/qstr.c
Loading
Please register or sign in to comment