Skip to content

Long Live Heap feature is worth mentioning in Differences from MicroPython #3825

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

Closed
kbanks-krobotics opened this issue Dec 15, 2020 · 8 comments

Comments

@kbanks-krobotics
Copy link

The use of both a long and short lifetime heap is different from MicroPython and probably worth mentioning in your docs, for example at

https://circuitpython.readthedocs.io/en/6.0.x/README.html#differences-from-micropython

  1. It's an opportunity to brag about a performance optimization :-)
  2. It's a pretty significant change behind the scenes, and it might catch people doing VM extensions by surprise

Things that don't move around in MicroPython between compile-time and execution-time can move around in CircuitPython.

FWIW

@kbanks-krobotics
Copy link
Author

Somebody please add a Documentation label to this - thanks!

@dhalbert dhalbert added this to the Long term milestone Dec 15, 2020
@tannewt
Copy link
Member

tannewt commented Dec 15, 2020

@kbanks-krobotics Want to make a PR with the addition?

@kbanks-krobotics
Copy link
Author

Insufficient time this evening, but something LIKE:
The CircuitPython VM uses the heap differently than MicroPython, treating the single physical heap as two logical heaps - one for short-lived items, the other for long-lived items. This helps reduce fragmentation, but does mean objects might get relocated between compilation and execution.

@tannewt
Copy link
Member

tannewt commented Dec 16, 2020

@kbanks-krobotics how are you hitting this? Are you adding a native module?

@kbanks-krobotics
Copy link
Author

Yes, I was porting over some features from a customized build of MicroPython (on STM32) to CircuitPython (on ESP32S2).
The features are part of a proprietary product line for now, but someday we hope to backport them into their ancestral codebases.
I agree "application-level" programmers are unlikely to be affected by this, but "system-level" programmers...

At the end of the project I will try to do a documentation PR with what I've learned (so far the "fancier heap" is the only architectural level difference I have noticed).

@tannewt
Copy link
Member

tannewt commented Dec 22, 2020

Ok, no problem! Please don't advertise it as CircuitPython until the changes are upstreamed.

This only matters when a native module holds onto a pointer usually. The Python references will be updated internally. (We only move at the end of an import before multiple copies can be made.)

@tekktrik
Copy link
Member

@kbanks-krobotics Are you still able to PR this? I'm doing some documentation things and am happy to PR what you wrote if not!

@dhalbert
Copy link
Collaborator

Rendered moot by #8281, which removed long-lived allocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants