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

Teardown compiler to improve rendering perf #6391

Merged
merged 5 commits into from
Mar 2, 2023
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 1, 2023

Changes

Use @astrojs/compiler teardown() API to remove the internal WASM instance and cache after we're finished with the Vite build.

Testing

All existing test should pass. !bench memory should show an improvement too, but it doesn't because the technique to capture "heap used" includes the garbage collection root (for some reason).

But when testing with docs locally, I can see the optimization working where Vite build memory gets offloaded during rendering.

Docs

n/a. internal refactor.

@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2023

🦋 Changeset detected

Latest commit: 6be32fd

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 1, 2023
@bluwy
Copy link
Member Author

bluwy commented Mar 1, 2023

!bench memory

@github-actions

This comment was marked as outdated.

@bluwy bluwy marked this pull request as ready for review March 1, 2023 15:28
@bluwy
Copy link
Member Author

bluwy commented Mar 1, 2023

This is good for review now. The !bench memory results above should be the same as the latest commit as they're using the same compiler.

@bluwy
Copy link
Member Author

bluwy commented Mar 1, 2023

Hmm. This seems to make CI tests even longer! I guess it's a double-edge sword with the teardown() API, where running builds many times causes the WASM instance to instantiate more times, slowing it down 🤔

Maybe we can skip teardown for tests for now.

@bluwy bluwy marked this pull request as draft March 1, 2023 16:11
@bluwy
Copy link
Member Author

bluwy commented Mar 2, 2023

!bench memory

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

PR Benchmark

Memory

Elapsed time (s) Memory used (MB) Final memory (MB)
SSR build 3.68 74.28 124.60
Client build 0.13 0.17 124.78
Static generate 0.58 4.57 128.84

Main Benchmark

Memory

Elapsed time (s) Memory used (MB) Final memory (MB)
SSR build 3.66 74.61 124.89
Client build 0.12 -0.20 124.78
Static generate 0.61 4.62 129.38

@bluwy bluwy marked this pull request as ready for review March 2, 2023 09:12
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Change to toggle the setting makes sense, still approved! 👍

@bluwy bluwy added this pull request to the merge queue Mar 2, 2023
Merged via the queue into main with commit 45501c5 Mar 2, 2023
@bluwy bluwy deleted the teardown-after-build branch March 2, 2023 14:56
@astrobot-houston astrobot-houston mentioned this pull request Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants