Skip to content

Handle very large .emb files.#215

Merged
reventlov merged 4 commits intogoogle:masterfrom
reventlov:convert_recursion_to_iteration
Dec 21, 2024
Merged

Handle very large .emb files.#215
reventlov merged 4 commits intogoogle:masterfrom
reventlov:convert_recursion_to_iteration

Conversation

@reventlov
Copy link
Contributor

This change switches parse tree handling to use iteration (with an explicit stack) instead of recursion, which:

  • Allows large (>~1000 entity) .emb files to be formatted.
  • Allows very large (>~16k entity) .emb files to be compiled.

The difference in sizes in the previous code was due to module_ir.py hackily increasing the recursion limit: while this more or less worked, it was a little dangerous (it ran the risk of blowing out the C stack, depending on platform) and only increased the limit. This change removes the limit entirely (at least, up to the available memory on the system).

This change switches parse tree handling to use iteration (with an
explicit stack) instead of recursion, which:

*   Allows large (>~1000 entity) `.emb` files to be formatted.
*   Allows very large (>~16k entity) `.emb` files to be compiled.

The difference in sizes in the previous code was due to `module_ir.py`
hackily increasing the recursion limit: while this more or less worked,
it was a little dangerous (it ran the risk of blowing out the C stack,
depending on platform) and only increased the limit.  This change
removes the limit entirely (at least, up to the available memory on the
system).
Copy link
Collaborator

@jasongraffius jasongraffius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants