-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
base: v6
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 an experimental, more performant 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. | ||||||
|
|
||||||
| 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
Show resolved
Hide resolved
|
||||||
|
|
||||||
| 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
Show resolved
Hide resolved
|
||||||
| ``` | ||||||
|
|
||||||
| This new rendering engine is designed to eventually replaced the current one. | ||||||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ## Configuration | ||||||
|
|
||||||
| The queued rendering engine comes with additional, low-level features, which allow you to experiment with other possible optimisations. These optimisations aren't directly part of the queued engine, and may be removed if they are proven inefficient during this experimental phase of testing. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Blame Americans. |
||||||
|
|
||||||
|
|
||||||
| ### Node pooling | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need an API reference |
||||||
| Node pooling is a caching system designed to re-use component nodes across renders. This feature is automatically enabled with a reasonable default according to our early testing. However, you can configure the size of the pool to increase or decrease the number of nodes combined in a single pool according to your project needs. To disable this feature entirely, set `poolSize` is `0`. | ||||||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| The node pooling is very effective when rendering static pages because it saves some memory when building websites with many pages that share the same components. | ||||||
|
|
||||||
| The node pooling is turned off for pages rendered on demand because these rendering requests do not share memory and there are therefore no savings to be gained with this strategy. | ||||||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ```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
Show resolved
Hide resolved
|
||||||
| ``` | ||||||
|
|
||||||
| ### Content caching | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here! |
||||||
| Content caching is another technique to re-use values (usually strings) during the rendering of page. Currently, this feature can only be enabled or disabled with no further configuration. It's disabled by default, but when enabled the experimental queued engine will choose a reasonable default cache size for most large content collections: | ||||||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ```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
Show resolved
Hide resolved
|
||||||
| ``` | ||||||
Uh oh!
There was an error while loading. Please reload this page.