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

Modified parse node definitions so they are all "monomorphic" (the sa… #8371

Closed
wants to merge 1 commit into from

Conversation

erictraut
Copy link
Collaborator

…me fields with the same layout). This helps the V8 engine optimize performance.

…me fields with the same layout). This helps the V8 engine optimize performance.
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@DanielRosenwasser
Copy link
Member

You mentioned elsewhere you weren't seeing quite the same speed improvement results as in microsoft/TypeScript#58928. One thing to note is that @dragomirtitian actually made three broader changes in that PR, and managed to untangle them into 3 separate PRs:

According to microsoft/TypeScript#58928 (comment), the win in monomorphizing types was the best one.

From this PR, it looks like you mostly changed syntax nodes. If you're seeing a ~5% improvement on average that probably checks out, though there might be other factors at play here too.

@erictraut
Copy link
Collaborator Author

@DanielRosenwasser, thanks for the additional info. I didn't realize that the changes in typescript went beyond syntax nodes. Yes, I suspect that making the type objects monomorphic will have a bigger impact than the parse nodes. It's a heavier lift to make that change, but it could be worth it.

@erictraut erictraut closed this Jul 11, 2024
@erictraut erictraut deleted the monomorph1 branch July 11, 2024 23:58
Comment on lines +86 to +94
delete analyzerNode.scope;
delete analyzerNode.declaration;
delete analyzerNode.flowNode;
delete analyzerNode.afterFlowNode;
delete analyzerNode.fileInfo;
delete analyzerNode.codeFlowExpressions;
delete analyzerNode.codeFlowComplexity;
delete analyzerNode.dunderAllInfo;
delete analyzerNode.typeParameterSymbol;

Choose a reason for hiding this comment

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

This categorically deoptimizes the internal maps. If possible set them to undefined instead.

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.

3 participants