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

Remove a few deopts already #4311

Closed
wants to merge 1 commit into from
Closed

Conversation

JoviDeCroock
Copy link
Member

I've started digging through the codebase on wins with regards to performance, I've seen a lot of them.... However, some of them also come down to our ... weird usage of TypeScript.

Let's take the Token as an example, we did a great thing in creating it as a class as it enforced consistent monomorphic backing shapes, however we do a non-null assertion, for the reason that value can actually be undefined. When we use Token we always assume that value is defined which makes all of this deopt as we will call functions with string | undefined the whole thing while our code is geared for string.

I've attempted to make value the correct type which resulted in a lot more issues.

In addition to that we have a lot of call-sites for the .slice method, we however do polymorphic access on it as adjacent call-sites will invoke String.slice right next to Array.slice which makes .slice not optimizeable, instead we can resort to converting String.slice into String.substring to avoid this issue all together.

The last noLocation parse bailout remaining is the .slice case of blockstring.ts

A tooltip showing us that a slice on a newly created array through .map deopts over polymorphic access

The improvements on the parser benchmark are currently minimal, I am trying to discover the deopts and how we can have a way forward.

Copy link

Hi @JoviDeCroock, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

TokenKind.PAREN_R,
position,
position + 1,
undefined,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistently calling createToken with 5 arguments helps V8 inline the cache

@JoviDeCroock JoviDeCroock deleted the improve-parser-perf branch December 16, 2024 08:30
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.

1 participant