6e5a40cf3c
The first dynamic qstr pool is double the size of the 'alloc' field of the last const qstr pool. The built in const qstr pool (mp_qstr_const_pool) has a hardcoded alloc size of 10, meaning that the first dynamic pool is allocated space for 20 entries. The alloc size must be less than or equal to the actual number of qstrs in the pool (the 'len' field) to ensure that the first dynamically created qstr triggers the creation of a new pool. When modules are frozen a second const pool is created (generally mp_qstr_frozen_const_pool) and linked to the built in pool. However, this second const pool had its 'alloc' field set to the number of qstrs in the pool. When freezing a large quantity of modules this can result in thousands of qstrs being in the pool. This means that the first dynamically created qstr results in a massive allocation. This commit sets the alloc size of the frozen qstr pool to 10 or less (if the number of qstrs in the pool is less than 10). The result of this is that the allocation behaviour when a dynamic qstr is created is identical with an without frozen code. Note that there is the potential for a slight memory inefficiency if the frozen modules have less than 10 qstrs, as the first few dynamic allocations will have quite a large overhead, but the geometric growth soon deals with this. |
||
---|---|---|
.. | ||
.gitattributes | ||
.gitignore | ||
bootstrap_upip.sh | ||
build-stm-latest.sh | ||
cc1 | ||
check_code_size.sh | ||
codestats.sh | ||
dfu.py | ||
file2h.py | ||
gen-changelog.sh | ||
gen-cpydiff.py | ||
gendoc.py | ||
insert-usb-ids.py | ||
make-frozen.py | ||
mpy_bin2res.py | ||
mpy_cross_all.py | ||
mpy-tool.py | ||
pyboard.py | ||
pydfu.py | ||
tinytest-codegen.py | ||
upip_utarfile.py | ||
upip.py |