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

Shrink the react key size in metadata RSC payload #50739

Merged
merged 6 commits into from Jun 6, 2023
Merged

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Jun 3, 2023

Follow up for #50678 as @gnoff commented in #50678 (review)

Now metadata is shorter with the shorter key with just numbers

self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team type: next labels Jun 3, 2023
@huozhi huozhi changed the title Reduce metadata key Reduce metadata flight response key Jun 3, 2023
@huozhi huozhi changed the title Reduce metadata flight response key Shrink the react key size in metadata RSC payload Jun 3, 2023
@huozhi huozhi marked this pull request as ready for review June 3, 2023 20:32
@huozhi huozhi requested a review from gnoff June 3, 2023 20:33
Copy link
Contributor

@gnoff gnoff left a comment

Choose a reason for hiding this comment

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

Approving because this will materially benefit the situation. However The approach still relies on layered filtering/mapping and a final clone at the end. When Metadata was first implemented I didn't have a good answer for why components were worse than functions but I think that with the current contraint of only emitting what is necessary it's clear that this should be refactored to use accumulation style functions rather than components. IMO the components don't really make it easier to read or contribute too and the necessitate a lot of allocations that really just aren't needed. Since we are writing lib code we need to favor perf more than an app might which can make better decisions around preferred abstractions relative to perf characteristics.

@huozhi
Copy link
Member Author

huozhi commented Jun 5, 2023

@gnoff I’ll think of how to refactor the whole structure, currently bit complex to pass down one counter to iterate across all components, wanna design a easy way to write it elegantly

@ijjk
Copy link
Member

ijjk commented Jun 5, 2023

Allow CI Workflow Run

  • approve CI run for commit: 2fc1df2

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@kodiakhq kodiakhq bot merged commit ec5ba31 into canary Jun 6, 2023
28 checks passed
@kodiakhq kodiakhq bot deleted the fix/metadata-key branch June 6, 2023 08:51
@alvarlagerlof
Copy link

Nice change! This was very noticeable in my RSC parser.

hydRAnger pushed a commit to hydRAnger/next.js that referenced this pull request Jun 12, 2023
Follow up for vercel#50678 as @gnoff commented in vercel#50678 (review)

Now metadata is shorter with the shorter key with just numbers

```
self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])
```
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants