-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
qstr: Separate hash and len from string data. #7209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Wow, great find! Need to run the performance benchmark to see if it has any impact there. Also see what the change is for RAM usage. |
This allows the compiler to merge strings: e.g. "update", "difference_update" and "symmetric_difference_update" will all point to the same memory. No functional change. ``` bare-arm: -12 -0.021% minimal x86: +38 +0.026% [incl +40(data)] unix x64: -576 -0.114% [incl +32(data)] unix nanbox: -696 -0.158% stm32: -1336 -0.344% PYBV10 cc3200: -440 -0.240% esp8266: -1092 -0.159% GENERIC esp32: -1332 -0.093% GENERIC[incl -1408(data)] nrf: -404 -0.273% pca10040 rp2: -1024 -0.213% PICO samd: -196 -0.190% ADAFRUIT_ITSYBITSY_M4_EXPRESS ``` Originally at adafruit#4583 Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
Originally at adafruit#4707 Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
I ran the performance benchmark on this PR, against master at 70f50c4. This is the result (perf0 is master, perf1 is this PR):
That's more or less no change. |
Ping? |
Against latest master, the size diff is now:
Performance change on PYBv1.1 is:
The new benchmarks that measure qstr interning now show quite good improvements. And other benchmarks are pretty much unchanged. That is good. The esp32 port (GENERIC on TinyPICO) also shows similar performance results to PYBv1.1:
The large improvements are probably because the qstr hashes are much more localised in flash and have better cache behaviour. |
Save code space by packing rgbw values into C union
This allows the compiler to merge strings: e.g. "update",
"difference_update" and "symmetric_difference_update"
will all point to the same memory.
No functional change.