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

perf(ast): box ImportDeclarationSpecifier enum variants #3061

Merged

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Apr 21, 2024

Part of #3047.

As with #3058, it's hard to interpret the benchmark results here. But in this case I think it's easier to see from "first principles" that this should be an improvement - ImportSpecifier is pretty massive (80 bytes) vs ImportDefaultSpecifier (40 bytes), and the latter (e.g. import React from 'react') is common in JS code.

@github-actions github-actions bot added A-parser Area - Parser A-ast Area - AST A-transformer Area - Transformer / Transpiler labels Apr 21, 2024
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @overlookmotel and the rest of your teammates on Graphite Graphite

Copy link

codspeed-hq bot commented Apr 21, 2024

CodSpeed Performance Report

Merging #3061 will not alter performance

Comparing 04-21-perf_ast_box_ImportDeclarationSpecifier_enum_variants (2e6ebdc) with main (84c43c8)

Summary

✅ 30 untouched benchmarks

@overlookmotel overlookmotel marked this pull request as ready for review April 21, 2024 19:38
@Boshen Boshen merged commit 383b449 into main Apr 22, 2024
35 checks passed
@Boshen Boshen deleted the 04-21-perf_ast_box_ImportDeclarationSpecifier_enum_variants branch April 22, 2024 01:06
Boshen pushed a commit that referenced this pull request Apr 22, 2024
Similar to #3058 and #3061 it is a continuation of #3047.

Handles these enum types:

> TSEnumMemberName
> Variant sizes: 16, 24, 24, 40
> Unboxed variants: IdentifierName (struct), StringLiteral (struct),
NumericLiteral (struct)
> Dependents: TSEnumMember (struct)
> => Box all variants.
>
> TSModuleReference 
> Variant sizes: 16, 32
> Unboxed variants: TSExternalModuleReference (struct)
> Dependents: Box<TSModuleReference> in TSImportEqualsDeclaration
> => Box all variants. Replace Box<TSModuleReference> with
TSModuleReference in TSImportEqualsDeclaration.
>
> TSTypePredicateName 
> Variant sizes: 8, 24
> Unboxed variants: IdentifierName (struct), TSThisType (struct)
> Dependents: TSTypePredicate (struct)
> => Box Identifier variant. Do not box This variant as only 8 bytes
(just contains Span).
>
> TSTypeQueryExprName 
> Variant sizes: 16, 88
> Unboxed variants: TSImportType (struct)
> Dependents: TSTypeQuery (struct)
> => Box TSImportType variant. Do not box TSTypeName variant, as is
another enum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-parser Area - Parser A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants