Skip to content

perf(jsdoc): skip should_attach_jsdoc when no remaining comments#22409

Merged
graphite-app[bot] merged 1 commit into
mainfrom
perf/jsdoc-skip-attach-when-empty
May 15, 2026
Merged

perf(jsdoc): skip should_attach_jsdoc when no remaining comments#22409
graphite-app[bot] merged 1 commit into
mainfrom
perf/jsdoc-skip-attach-when-empty

Conversation

@Boshen

@Boshen Boshen commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

JSDocBuilder::retrieve_attached_jsdoc is called for every AST node during the semantic build. Even when the source contains no JSDoc comments, the per-node should_attach_jsdoc(kind) matches! over 33 variants still runs.

This adds a fast-path early return when not_attached_docs is empty — true for files with no JSDoc, and for the tail of every walk once all comments have been attached — and marks retrieve_attached_jsdoc #[inline] so the guard fuses into SemanticBuilder::create_ast_node.

Measurements

xcrun xctrace record --template 'Time Profiler', semantic stage on the standard benchmark inputs. Profile binary built with --profile release-with-debug.

retrieve_attached_jsdoc self-time:

file before after
antd.js (6.7M, sparse JSDoc) 2.59% 0.04%
checker.ts (2.8M, JSDoc throughout) 3.23% 0.17%

Hot-path bundle (retrieve + should_attach + create_ast_node) drops ~2pp on both files. Wall-time on 50 iters of parse+semantic: antd −9%, checker −8%, cal.com.tsx −5%.

Notes

  • should_attach_jsdoc still runs when there are comments left to attach, so behavior is unchanged.
  • The #[inline] lets LLVM fuse the empty-map check into the visitor body, which is what amplifies the win on JSDoc-heavy inputs (the guard fires once all comments are placed).

🤖 Generated with Claude Code

@codspeed-hq

codspeed-hq Bot commented May 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing perf/jsdoc-skip-attach-when-empty (78557a2) with main (618bc76)

Open in CodSpeed

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.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 15, 2026

Boshen commented May 15, 2026

Copy link
Copy Markdown
Member Author

Merge activity

)

## Summary

`JSDocBuilder::retrieve_attached_jsdoc` is called for every AST node during the semantic build. Even when the source contains no JSDoc comments, the per-node `should_attach_jsdoc(kind)` `matches!` over 33 variants still runs.

This adds a fast-path early return when `not_attached_docs` is empty — true for files with no JSDoc, and for the tail of every walk once all comments have been attached — and marks `retrieve_attached_jsdoc` `#[inline]` so the guard fuses into `SemanticBuilder::create_ast_node`.

## Measurements

`xcrun xctrace record --template 'Time Profiler'`, semantic stage on the standard benchmark inputs. Profile binary built with `--profile release-with-debug`.

`retrieve_attached_jsdoc` self-time:

| file | before | after |
|---|---|---|
| antd.js (6.7M, sparse JSDoc) | 2.59% | **0.04%** |
| checker.ts (2.8M, JSDoc throughout) | 3.23% | **0.17%** |

Hot-path bundle (retrieve + should_attach + create_ast_node) drops ~2pp on both files. Wall-time on 50 iters of parse+semantic: antd −9%, checker −8%, cal.com.tsx −5%.

## Notes

- `should_attach_jsdoc` still runs when there are comments left to attach, so behavior is unchanged.
- The `#[inline]` lets LLVM fuse the empty-map check into the visitor body, which is what amplifies the win on JSDoc-heavy inputs (the guard fires once all comments are placed).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app Bot force-pushed the perf/jsdoc-skip-attach-when-empty branch from 78557a2 to dbbc059 Compare May 15, 2026 15:31
@graphite-app graphite-app Bot merged commit dbbc059 into main May 15, 2026
28 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 15, 2026
@graphite-app graphite-app Bot deleted the perf/jsdoc-skip-attach-when-empty branch May 15, 2026 15:35
camc314 pushed a commit that referenced this pull request May 18, 2026
### 🐛 Bug Fixes

- 0f26de6 ecmascript: Resolve identifier value type via tracked
constants (#22234) (Alexander Lichter)
- c27a8cf minifier: Normalize `{ x: x }` shorthand so adjacent-if merge
is idempotent (#22401) (Dunqing)
- e431a0e parser: Break extends clause loop on fatal error (#22517)
(Boshen)
- e9ec7c6 minifier: Fold optional chains by base nullishness (#22236)
(Alexander Lichter)
- e6090e7 transformer: Keep enum IIFE when a non-inlinable value
reference remains (#22501) (Dunqing)
- 931b7d6 transformer: Inline const enum members through type-cast
wrappers (#22500) (Dunqing)
- b9615b2 codegen: Preserve string quotes in require() calls during
minification (#22475) (zennnnnnn11)
- c73c159 transformer/async-to-generator: Reparent parameter initializer
scopes (#22507) (camc314)
- ecfd3ca transformer/async-to-generator: Move only parameter bindings
(#22503) (camc314)
- 3ce3431 transformer/explicit-resource-managment: Preserve shadowed
for-head block (#22451) (camc314)

### ⚡ Performance

- ce92c6c semantic: `#[inline]` `Scoping::get_binding` (#22414)
(Dunqing)
- 98be95c regular_expression: Track regex flags via bitflags (#22427)
(Boshen)
- dbbc059 jsdoc: Skip should_attach_jsdoc when no remaining comments
(#22409) (Boshen)
- 217d7d8 minifier: Index `SymbolValues` by `SymbolId` (#22441)
(Dunqing)
- d782b78 minifier: Use BitSet for LiveUsageCollector live references
(#22425) (Boshen)
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