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

Use AsyncLocalStorage if available #5

Closed
mcollina opened this issue Apr 22, 2020 · 5 comments
Closed

Use AsyncLocalStorage if available #5

mcollina opened this issue Apr 22, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mcollina
Copy link

https://nodejs.org/dist/latest-v14.x/docs/api/async_hooks.html#async_hooks_class_asynclocalstorage provides a very similar experience of cls-hooked at a fraction of the overhead. It should use that instead when/if available.

@thorough-developer thorough-developer added the enhancement New feature or request label Apr 22, 2020
@thorough-developer thorough-developer self-assigned this Apr 22, 2020
@thorough-developer
Copy link
Owner

@mcollina Good call! I will look into implementing this asap!

@thorough-developer
Copy link
Owner

@mcollina Am I waiting on this PR: nodejs/node#32318 ? for a backport to 12?

@thorough-developer
Copy link
Owner

thorough-developer commented Apr 22, 2020

@mcollina Got this implemented. I see a 33% increase in performance on average which is pretty amazing. Just waiting on the backport: https://github.com/thorough-developer/fastify-http-context/tree/async-local-storage

@mcollina
Copy link
Author

I know :). I was part of the team that came up with the theory that makes it possible to be faster.

@thorough-developer
Copy link
Owner

Done #6

Added a conditional to handle whether the class was available. So 13+ and hopefully 12 soon will get the performance boost. Thanks for the suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants