aboutsummaryrefslogtreecommitdiff
path: root/tests/import
diff options
context:
space:
mode:
authorDamien George2019-02-25 23:15:51 +1100
committerDamien George2019-03-05 16:25:07 +1100
commit5996eeb48fa6ce773003eacbc7e0b52ad5cc4d31 (patch)
treeb5a1fe800073108d5da9abf84c59aa5387ec537e /tests/import
parent5a2599d96299ad37cda954f1de345159f9acf11c (diff)
py/persistentcode: Add a qstr window to save mpy files more efficiently.
This is an implementation of a sliding qstr window used to reduce the number of qstrs stored in a .mpy file. The window size is configured to 32 entries which takes a fixed 64 bytes (16-bits each) on the C stack when loading/saving a .mpy file. It allows to remember the most recent 32 qstrs so they don't need to be stored again in the .mpy file. The qstr window uses a simple least-recently-used mechanism to discard the least recently used qstr when the window overflows (similar to dictionary compression). This scheme only needs a single pass to save/load the .mpy file. Reduces mpy file size by about 25% with a window size of 32.
Diffstat (limited to 'tests/import')
-rw-r--r--tests/import/mpy_invalid.py1
-rw-r--r--tests/import/mpy_invalid.py.exp1
2 files changed, 2 insertions, 0 deletions
diff --git a/tests/import/mpy_invalid.py b/tests/import/mpy_invalid.py
index 6a4e116e7..6e9cbc9db 100644
--- a/tests/import/mpy_invalid.py
+++ b/tests/import/mpy_invalid.py
@@ -48,6 +48,7 @@ user_files = {
'/mod0.mpy': b'', # empty file
'/mod1.mpy': b'M', # too short header
'/mod2.mpy': b'M\x00\x00\x00', # bad version
+ '/mod3.mpy': b'M\x00\x00\x00\x7f', # qstr window too large
}
# create and mount a user filesystem
diff --git a/tests/import/mpy_invalid.py.exp b/tests/import/mpy_invalid.py.exp
index 1727ea1ce..ea748ff6c 100644
--- a/tests/import/mpy_invalid.py.exp
+++ b/tests/import/mpy_invalid.py.exp
@@ -1,3 +1,4 @@
mod0 ValueError incompatible .mpy file
mod1 ValueError incompatible .mpy file
mod2 ValueError incompatible .mpy file
+mod3 ValueError incompatible .mpy file