Skip to content
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

feat(stdlib): Optimize List.init to support large lists #2249

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

spotandjake
Copy link
Member

@spotandjake spotandjake commented Feb 17, 2025

This pr optimizes List.init to support large allocations without overflowing the call stack.

On lists smaller than 2500 we use the old approach and for anything else we use a tco approach build the list and then reverse it.

Notes

  • 2500 is a rather arbitrary choice to switch over, We start having stack overflows with the grain runner around 5k elements and I figured other runtimes might have smaller stacks so it probably makes sense to switch over before that.
    • If we choose to low a number we leave performance on the table because of the List.reverse overhead
    • If we choose to high a number we could overflow the wasm call stack.
  • feat(runtime): Optimize == for lists  #2247 needs to be merged before this for tests to pass.

@spotandjake spotandjake force-pushed the spotandjake-large-lst-init branch from 9cf7970 to ad296ad Compare February 18, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant