Skip to content

Allocate memory from the parser in "pspace", not GC space #205

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jpco
Copy link
Collaborator

@jpco jpco commented Apr 25, 2025

This change itself does not change anything for the user -- as far as I can tell, it doesn't even have a noticeable performance or memory-use impact to speak of. It does add some code complexity, but I believe it's worth it.

The upside of this change is that it removes the major technical blocker for running es functions while fetching input -- meaning that things like programmable key bindings, completions, line-by-line history-writing (as opposed to the per-command history writing after #65), and more (see #178) are all now possible with this change.

How it works is that it defines a new memory "space" called "pspace", where any parser-related GC-like memory allocations go. Unlike normal GC space, pspace is never automatically collected, and is in fact manually collected at the end of a parse run. Live data during pspace collection (called pseal in the codebase) is copied into GC space where it begins to act like any other GC'd data. This makes "pspace" into a sort of special-purpose "nursery" like for a generational GC.

The next follow-up to this will be making it possible to run more than one parser at a time, such that es code that needs to be parsed from a string before running can do so when the parser is already active. After that, the sky is the limit.

jpco and others added 3 commits April 12, 2025 19:12
Two major TODOs:

 - Resolve TODOs in gc.c

 - Fix the extremely sneaky memory bug hiding somewhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant