Skip to content

perf: build transport encoders once instead of on every response - #16406

Closed
Nic-Polumeyv wants to merge 5 commits into
sveltejs:version-3from
Nic-Polumeyv:perf-memoize-transport-encoders
Closed

Nic-Polumeyv wants to merge 5 commits into
sveltejs:version-3from
Nic-Polumeyv:perf-memoize-transport-encoders

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

The encode map derived from the transport hook was rebuilt on every serialized response: every __data.json request, every form action response, and every remote function response, including each push from a query.live loop.

It only depends on the transport hook, which is fixed at server init, where the mirror decoders map is already built. Both now come from one pass there, matching what the client manifest already does.

The uneval paths are untouched since create_replacer iterates the transport lazily.

No new test, the existing serialization and remote function suites cover both.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from c20b5a6:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/c20b5a65f2bf6d4fb3df9cbef91a95bff242245c

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16406

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c20b5a6

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review July 18, 2026 15:32
…ransport-encoders

# Conflicts:
#	packages/kit/src/runtime/server/page/actions.js
#	packages/kit/src/runtime/server/page/data_serializer.js
…ransport-encoders

# Conflicts:
#	packages/kit/src/runtime/app/server/remote/prerender.js
#	packages/kit/src/runtime/server/page/actions.js
@Rich-Harris Rich-Harris mentioned this pull request Aug 5, 2026
3 of 6 tasks
@Rich-Harris

Copy link
Copy Markdown
Member

This is the right idea but we can take it a lot further — closing this in favour of #16658

@Rich-Harris Rich-Harris closed this Aug 5, 2026
elliott-with-the-longest-name-on-github added a commit that referenced this pull request Aug 5, 2026
This is #16406 but takes the idea to its logical conclusion: by having
an internal module where this stuff is managed, we don't need to pass
anything around at all and can delete/simplify a bunch of stuff. Once
this is in, will rebase #14129 against `version-3` and update it to use
this.

Co-authored-by: Elliott Johnson <[email protected]>
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