-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
experimental queued rendering #13299
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b078b40
feat: document queued rendering
ematipico db18ebc
Merge branch 'v6' into feat/queued-rendering
ArmandPhilippot deb1ada
Apply suggestions from code review
ematipico 1c9e3be
Apply suggestions from code review
ematipico af7083c
Apply suggestions from code review
ematipico c1e6f91
add types
ematipico 0746ffa
Merge remote-tracking branch 'origin/v6' into feat/queued-rendering
ematipico 2e232e7
Update astro.sidebar.ts
ematipico 9b4643d
Merge branch 'v6' into feat/queued-rendering
sarah11918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/content/docs/en/reference/experimental-flags/queued-rendering.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: Experimental queued rendering | ||
| sidebar: | ||
| label: Queued rendering | ||
| i18nReady: true | ||
| --- | ||
|
|
||
| import Since from '~/components/Since.astro'; | ||
|
|
||
| <p> | ||
|
|
||
| **Type:** `object`<br /> | ||
| **Default:** `{ enabled: false }`<br /> | ||
| <Since v="6.0.0" /> | ||
| </p> | ||
|
|
||
| Enables a different rendering infrastructure that is based on a queue instead of recursion. | ||
|
|
||
| By default, Astro renders `.astro`, `.md` and `.mdx` files using a recursion algorithm. It takes as input a series of components that are serialised in a tree-like structure, and for each node of the tree, Astro calls a render function.0 | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| When queued rendering is enabled, Astro traverses all nodes in the tree, and emits a [depth-first](https://en.wikipedia.org/wiki/Depth-first_search) list of nodes. This list is then iterated and rendered, without the need of a recursion algorithm. This rendering is more memory efficient, and it should provide more benefits in big projects. | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| To enable this feature with default settings, set `queuedRendering.enabled` to `true` in your Astro config: | ||
|
|
||
| ```js title="astro.config.mjs" ins={5-7} | ||
| import { defineConfig } from "astro/config" | ||
|
|
||
| export default defineConfig({ | ||
| experimental: { | ||
| queuedRendering: { | ||
| enabled: true | ||
| } | ||
| } | ||
| }) | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| This new rendering engine is designed to eventually replaced the current one. | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Configuration | ||
|
|
||
| The queued rendering engine comes with additional, low-level features, which allow to experiment with other possible optimisations. These optimisations aren't directly part of the queue engine, which means that they could be removed if they are proven inefficient. | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| ### Node pooling | ||
|
|
||
|
ematipico marked this conversation as resolved.
|
||
| Node pooling is a caching system designed to re-use component nodes across renders. This feature *is automatically enabled*, however you can configure the size of the pool. When the field `poolSize` is `0`, the feature isn't used. | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| The node pooling is very effective when rendering static pages, and it allows to save some memory when building websites with many pages that share the same components. | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| The node pooling is turned off when rendering dynamic pages, because rendering requests don't share memory | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```js title="astro.config.mjs" ins={7} | ||
| import { defineConfig } from "astro/config" | ||
|
|
||
| export default defineConfig({ | ||
| experimental: { | ||
| queuedRendering: { | ||
| enabled: true, | ||
| poolSize: 3000 // use a pool of 3000 nodes | ||
| } | ||
| } | ||
| }) | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| ### Content caching | ||
|
|
||
|
ematipico marked this conversation as resolved.
|
||
| Content caching is another technique to re-use values (usually strings) during the rendering of page. It's less configurable than node pooling, as you can only turn it on or off. It's disabled by default: | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```js title="astro.config.mjs" ins={7} | ||
| import { defineConfig } from "astro/config" | ||
|
|
||
| export default defineConfig({ | ||
| experimental: { | ||
| queuedRendering: { | ||
| enabled: true, | ||
| contentCache: true | ||
| } | ||
| } | ||
| }) | ||
|
ematipico marked this conversation as resolved.
Outdated
|
||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.