-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
perf(remix-server-runtime): use json.parse for route manifest #5555
Conversation
🦋 Changeset detectedLatest commit: 4739fbf The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
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 |
This PR has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this PR will be automatically closed. |
@redabacha Would you mind rebasing your PR and fixing the conflicts ? 🙏🏼 |
done ✔️ |
@@ -107,7 +107,7 @@ export const write = async (config: RemixConfig, assetsManifest: Manifest) => { | |||
|
|||
await writeFileSafe( | |||
path.join(config.assetsBuildDirectory, filename), | |||
`window.__remixManifest=${JSON.stringify(assetsManifest)};` | |||
`window.__remixManifest=JSON.parse('${JSON.stringify(assetsManifest)}');` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 4739fbf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only concern with the double JSON.stringify
is the added bytes over the wire due to the \\
escaping though - but the manifest oughta be cached to alleviate that after the first load?
|
Just as a note, I don't think we can fully trust the benchmarks reported here since they're from Node on a 16-core machine. The thing aiming to be sped up here is the cost of reading the manifest in the browser on the client device, not necessarily a 16-core node CPU. I would expect to see better results on a slower device/CPU, but would want to see real RUM data before declaring this approach as "better". |
Closes: #
Testing Strategy:
used JSON.parse in the generated code for adding the route manifest as it's faster than using an object literal, see https://v8.dev/blog/cost-of-javascript-2019#json
created benchmarks here: https://github.com/redabacha/remix-manifest-json-parse. it's anywhere from 1x to 2x faster depending on the number of routes in the manifest (the more routes the larger the performance difference from what i've observed).