Skip to content

perf(parser): do not re-allocate TS interface heritage#17692

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-05-perf_parser_do_not_re-allocate_ts_interface_heritage
Jan 6, 2026
Merged

perf(parser): do not re-allocate TS interface heritage#17692
graphite-app[bot] merged 1 commit intomainfrom
01-05-perf_parser_do_not_re-allocate_ts_interface_heritage

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Jan 6, 2026

this was a small refactor that came out of removing the extra pass for counting nodes in semantic. this is the only place (as far as I can tell) that we don't use the AstBuilder functions in the parser.

  • updated parsing code to use AstBuilder instead of TSInterfaceHeritage { ... } directly
  • reduced allocations by returning TSInterfaceHeritage directly from parsing functions, instead of its constituent data

Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

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

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Jan 6, 2026
@camchenry camchenry force-pushed the 01-05-perf_parser_do_not_re-allocate_ts_interface_heritage branch from 5464329 to 10375f4 Compare January 6, 2026 04:24
@camchenry camchenry marked this pull request as ready for review January 6, 2026 04:26
Copilot AI review requested due to automatic review settings January 6, 2026 04:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the TypeScript interface heritage parsing to reduce memory allocations by eliminating an unnecessary intermediate representation. Instead of parsing heritage clauses into tuples and then reconstructing TSInterfaceHeritage objects, the parser now directly returns TSInterfaceHeritage objects using the AstBuilder API.

Key changes:

  • Updated parse_extends_clause to use AstBuilder::ts_interface_heritage and return TSInterfaceHeritage objects directly
  • Simplified heritage clause handling in TypeScript interface parsing by removing the intermediate tuple-to-struct mapping
  • Reduced arena allocations as evidenced by the snapshot changes (1 allocation saved in checker.ts, 3 in cal.com.tsx)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tasks/track_memory_allocations/allocs_parser.snap Updated allocation benchmarks showing reduction in arena allocations for test files
crates/oxc_parser/src/ts/statement.rs Simplified interface declaration parsing by removing the tuple-to-TSInterfaceHeritage mapping step
crates/oxc_parser/src/js/class.rs Refactored parse_extends_clause to return TSInterfaceHeritage directly and use AstBuilder API; updated heritage clause parsing and class parsing to use the new structure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 6, 2026

CodSpeed Performance Report

Merging #17692 will not alter performance

Comparing 01-05-perf_parser_do_not_re-allocate_ts_interface_heritage (10375f4) with main (6f65901)

Summary

✅ 42 untouched
⏩ 3 skipped1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Jan 6, 2026
Copy link
Member

Dunqing commented Jan 6, 2026

Merge activity

- related to oxc-project/backlog#74

this was a small refactor that came out of removing the extra pass for counting nodes in semantic. this is the only place (as far as I can tell) that we don't use the `AstBuilder` functions in the parser.

- updated parsing code to use `AstBuilder` instead of `TSInterfaceHeritage { ... }` directly
- reduced allocations by returning `TSInterfaceHeritage` directly from parsing functions, instead of its constituent data
@graphite-app graphite-app bot force-pushed the 01-05-perf_parser_do_not_re-allocate_ts_interface_heritage branch from 10375f4 to 3f4429c Compare January 6, 2026 09:46
@graphite-app graphite-app bot merged commit 3f4429c into main Jan 6, 2026
21 checks passed
@graphite-app graphite-app bot deleted the 01-05-perf_parser_do_not_re-allocate_ts_interface_heritage branch January 6, 2026 09:52
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 6, 2026
Dunqing pushed a commit that referenced this pull request Jan 12, 2026
### 🚀 Features

- 10426af codegen: Print soft space between inline block comments on the
same line (#17799) (camc314)
- 2261e6e semantic: Improve error message to add `#` for private
identifiers (#17779) (Dunqing)

### 🐛 Bug Fixes

- 7422b7e parser/trivia: Correctly mark whether a block comment is on a
newline (#17754) (camc314)
- c32e8d5 codegen: Wrap `TSAsExpression` in parens when used with
in/instanceof operators (#17752) (camc314)
- 5755b2d semantic: Report duplicate private identifier for static and
instance elements (#17591) (camc314)
- 0600df3 isolated_declarations: Only print jsdoc comments (#17748)
(camc314)
- ef7e014 parser: Preserve `@__NO_SIDE_EFFECTS__` annotation with
parenthesized expressions (#17711) (camc314)
- 59a6228 parser: Detect TS1363 error for type-only imports with mixed
default and named/namespace bindings (#17712) (Copilot)

### ⚡ Performance

- 864f1fa semantic: Mark duplicate class element error reporting as cold
(#17746) (camc314)
- 3a452b8 semantic: Use smallvec for storing reference IDs (#17731)
(camchenry)
- d5979dc minifier: Do not allocate when checking to convert `const` to
`let` (#17730) (camchenry)
- 3f4429c parser: Do not re-allocate TS interface heritage (#17692)
(camchenry)

### 📚 Documentation

- 120a27c minifier: Add prettier-ignore for js-in-md part (#17687)
(leaysgur)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants