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

perf(vite): simplify manifest property acccess #24715

Merged
merged 3 commits into from Dec 14, 2023

Conversation

GalacticHypernova
Copy link
Contributor

@GalacticHypernova GalacticHypernova commented Dec 12, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR caches each key in the client manifest to improve performance and decrease the manifest handling time. Tested with core-js package.json file, performance is increased by ~90% (view second attachment):
image

And with native console.time/timeEnd:
image

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Dec 12, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@GalacticHypernova GalacticHypernova marked this pull request as draft December 12, 2023 18:15
@github-actions github-actions bot added the 3.x label Dec 12, 2023
@GalacticHypernova GalacticHypernova marked this pull request as ready for review December 12, 2023 18:16
@GalacticHypernova
Copy link
Contributor Author

(The failing test has nothing to do with the PR whatsoever, and might be worth fixing in the test case itself)

@danielroe
Copy link
Member

This is run once after the vite build, and iterates over every file emitted from the vite client build.

I would not imagine there is a significant difference in time between 6x accesses of a deep property and 1x access of deep property and 5x one level less. But I'm happy to be proved wrong.

How did you run the test in the issue?

@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 13, 2023

@danielroe
clientManifest is the core-js package-lock.json file (won't paste it here because it's too large), BASE_RE is new RegExp('abcde')
Rest of the code is:
repeatedIndex: the same as the current file
cachedAccess: this PR
Same goes for all my perf PR's

Offline testing supports this as well:
image

@danielroe danielroe changed the title perf(vite): cache repeated manifest access perf(vite): simplify manifest property acccess Dec 14, 2023
@danielroe danielroe merged commit 4e0d2c0 into nuxt:main Dec 14, 2023
34 checks passed
@github-actions github-actions bot mentioned this pull request Dec 14, 2023
@GalacticHypernova GalacticHypernova deleted the patch-10 branch December 15, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants