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

Cache the evaluation of ParseInputLazyPath.path() for a moderate perf improvement #2137

Merged
merged 4 commits into from Mar 5, 2023

Conversation

jussisaurio
Copy link
Contributor

Hi, thanks for the great library, I adore the API :)

I was looking for ways to make some unintrusive improvements to the performance, and noticed since a ParseInput's path may be evaluated multiple times, caching the evaluation result avoids some extra array allocations.

Around a 10% speedup on 'realworld' on my computer.

Dunno what happened with the rest of the diff, I don't think I touched anything or had "format on save" on...

A ParseInput's path may be evaluated multiple times,
so caching the evaluation result avoids some extra
array allocations.

Around a 10% speedup on 'realworld'.
@netlify
Copy link

netlify bot commented Mar 3, 2023

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
🔨 Latest commit 0a873fa
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/640464b7e2490d00084d24da
😎 Deploy Preview https://deploy-preview-2137--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@colinhacks
Copy link
Owner

Thanks! Simplified the implementation a bit.

@jussisaurio
Copy link
Contributor Author

Hi! The changed code is definitely simpler, but at least on my machine it wipes out the perf improvement almost completely. I am guessing that Array.prototype.concat is just fundamentally a lot slower than allocating an empty array and then pushing into it.

@colinhacks
Copy link
Owner

Ah interesting. Guess getting rid of .concat matters more than the caching bit. Sorry, I should have re-run the benchmarks. I'll revert.

@colinhacks colinhacks merged commit 03c0ab1 into colinhacks:master Mar 5, 2023
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.

None yet

2 participants