-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix: make asString monomorphic and trigger V8 optimization #689
Conversation
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.
Definetly needs great consensus
@ivan-tymoshenko
@mcollina
@climba03003
@gurgunday
@kibertoad
I propose the necessity of atleast 3 approvals.
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.
lgtm
makes 100% sense |
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.
LGTM
Should types be adjusted accordingly? |
Which types? |
@Uzlopak checked https://github.com/fastify/fast-json-stringify/blob/master/types/index.d.ts, it doesn't seem to be there. so it's an internal only method? |
yup, only internal |
asString is Polymorphic/Megamorphic because accept more type (string, date, regex, null)
So let’s spend some more time defining this.
In short: functions that are invoked with the same types over and over again are optimized in the JIT compiler, hence faster.
Megamorphism asString (actual code)
Monomorphic asString (my PR)
Checklist
npm run test
andnpm run benchmark
and the Code of conduct