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(schema): use parallel promises #24771

Merged
merged 13 commits into from Dec 15, 2023
Merged

Conversation

GalacticHypernova
Copy link
Contributor

@GalacticHypernova GalacticHypernova commented Dec 15, 2023

πŸ”— Linked issue

#24734

❓ 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

Following the linked PR, @pi0 brought to my attention that we can use parallel promises, and indeed the benchmark shows a significant ~30% improvement in performance, so all credits of this PR are to him.

async function main(){
async function get(name:string){
    return 42;
  }
  console.time("current")
  for (let index = 0; index < 1000000; index++) {
   const a = await get('a')
   const b = await get('b')
   const c = await get('c')
   const d = await get('d')
    
  }
console.timeEnd("current")
console.time("PR")
for (let index = 0; index < 1000000; index++) {
    const [a,b,c,d]=await Promise.all([get('a'), get('b'), get('c'), get('d')])
    
  }
  console.timeEnd("PR")
}
main()

image

πŸ“ Checklist

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

Copy link

stackblitz bot commented Dec 15, 2023

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

@github-actions github-actions bot added the 3.x label Dec 15, 2023
@GalacticHypernova
Copy link
Contributor Author

Marking as draft while I'm checking to see if anything else can be parallelized

@GalacticHypernova GalacticHypernova marked this pull request as draft December 15, 2023 10:55
@GalacticHypernova GalacticHypernova marked this pull request as ready for review December 15, 2023 11:11
@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 15, 2023

Pretty sure that's everything.
I will try to fix the issues.

@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 15, 2023

I still don't quite get why the tests are failing, I don't see any "unexpected token"...
Unless I'm missing something of course, which is possible.

@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 15, 2023

Ah I see, looking back at it. I could've sworn without parentheses was fine when I tested but I probably mistook it for something, my bad

@danielroe danielroe merged commit 153d5ff into nuxt:main Dec 15, 2023
34 checks passed
@github-actions github-actions bot mentioned this pull request Dec 15, 2023
@GalacticHypernova GalacticHypernova deleted the patch-19 branch December 15, 2023 14:34
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

3 participants