-
Notifications
You must be signed in to change notification settings - Fork 100
Conway - performance improvements using micropython and memory management changes #448
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
base: main
Are you sure you want to change the base?
Conversation
Refactor Conway class for performance improvements. Optimize memory usage with 1D arrays and micropython native/ iper functions.
|
Thanks for this! Looks like the CI testing is going to need to get updated to handle the native code decorations, which isn't surprising. I'll load this onto one of my modules and give it a try. Hopefully the performance increase is enough that we can add the option to externally clock each generation (an early idea that got dumped because of the generally bad performance). |
Ah yes, I think unfortunately the viper decorator function may cause some issues there since it's not fully python standards compliant. Hopefully it won't cause too much a headache. It should absolutely work when loaded onto a hardware europi though. It's definitely faster, but I suspect not quite fast enough for external clocking. I haven't tested it with a raspberry pi Pico 2 but I suspect you may be able to externally clock it on that but not the Pico 1. I even began to expand into other cellular automata and created a way for simulation and CV functionality to be modular and extensible by having them be seperate scripts that can be loaded in somewhat similar to the menu script does, but specifically for the cellular automata rules. If you like, I can share the all-in-one version that just uses the Conway ruleset and then also share the extensible cellular automata version separately. :) |
|
If you've got a better refactoring of this script, I'm definitely open to removing this one and replacing it with your new one instead. I'm a fan of reducing duplication where possible. |
|
Okey dokey, I'll spend some time cleaning it up to meet contrib submit standards and I'll share it here (possibly a seperate PR) for you, I think you'll enjoy it :) |
|
I'm looking forward to seeing it! |
Overview
This PR introduces significant performance optimizations to the existing Conway's Game of Life contrib script. The changes focus on improving execution speed and memory efficiency on the Raspberry Pi Pico's constrained hardware while maintaining full compatibility with the existing API and functionality.
Rationale
These optimizations address the specific constraints of the Raspberry Pi Pico's MicroPython environment, where:
External Docs
Maximising micropython speed
https://docs.micropython.org/en/v1.9.3/pyboard/reference/speed_python.html#maximising-micropython-speed
@micropython.native
https://docs.micropython.org/en/v1.9.3/pyboard/reference/speed_python.html#the-native-code-emitter
@micropython.viper
https://docs.micropython.org/en/v1.9.3/pyboard/reference/speed_python.html#the-viper-code-emitter
Changes Made:
Memory Management Improvements:
Performance Optimizations:
Bug Fixes:
Technical Impact
Performance Benefits:
Memory Usage:
Final Note