Skip to content

perf(linter/no-redeclare): avoid repeated PHF hashmap lookups#18248

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-perf_linter_no-redeclare_avoid_repeated_phf_hashmap_lookups
Jan 19, 2026
Merged

perf(linter/no-redeclare): avoid repeated PHF hashmap lookups#18248
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-perf_linter_no-redeclare_avoid_repeated_phf_hashmap_lookups

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 19, 2026

Looking up GLOBALS["builtin"] is not so cheap (PHF hashmaps use quite a slow hash function). Do the lookup once only outside the loop, rather than repeatedly for each symbol.

There is a more comprehensive solution - oxc-project/javascript-globals#149 - but this is should be an improvement in the meantime.

@github-actions github-actions bot added A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance labels Jan 19, 2026
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.

@overlookmotel overlookmotel marked this pull request as ready for review January 19, 2026 14:55
Copilot AI review requested due to automatic review settings January 19, 2026 14:55
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 optimizes the no-redeclare linter rule by caching the GLOBALS["builtin"] hashmap lookup outside the loop that iterates over all symbols. This avoids repeated expensive PHF hashmap lookups for each symbol when builtin_globals is enabled.

Changes:

  • Cache GLOBALS["builtin"] before the symbol iteration loop to avoid repeated hashmap lookups
  • Refactor the builtin check to use is_some_and with the cached value

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing om/01-19-perf_linter_no-redeclare_avoid_repeated_phf_hashmap_lookups (a89ddea) with main (2ef5647)

Summary

✅ 4 untouched benchmarks
⏩ 41 skipped benchmarks1

Footnotes

  1. 41 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.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
Copy link
Contributor

camc314 commented Jan 19, 2026

Merge activity

Looking up `GLOBALS["builtin"]` is not so cheap (PHF hashmaps use quite a slow hash function). Do the lookup once only outside the loop, rather than repeatedly for each symbol.

There is a more comprehensive solution - oxc-project/javascript-globals#149 - but this is should be an improvement in the meantime.
@graphite-app graphite-app bot force-pushed the om/01-19-perf_linter_no-redeclare_avoid_repeated_phf_hashmap_lookups branch from a89ddea to 1a247f1 Compare January 19, 2026 15:11
@graphite-app graphite-app bot merged commit 1a247f1 into main Jan 19, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/01-19-perf_linter_no-redeclare_avoid_repeated_phf_hashmap_lookups branch January 19, 2026 15:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
@overlookmotel
Copy link
Member Author

@camc314 You're on holiday! You can review PRs when you get back. If it was urgent, I'd have merged myself.

overlookmotel added a commit that referenced this pull request Jan 19, 2026
# Oxlint
### ⚡ Performance

- 1a247f1 linter/no-redeclare: Avoid repeated PHF hashmap lookups
(#18248) (overlookmotel)

### 📚 Documentation

- 8a294d5 oxfmt, oxlint: Update logo (#18242) (Dunqing)
# Oxfmt
### 🐛 Bug Fixes

- 864b4ab oxfmt: Use `format_config` for `external_options` override
(#18252) (leaysgur)
- 90ce4b7 oxfmt: Restore `customGroups` handling lost (#18243)
(leaysgur)

### 📚 Documentation

- 8a294d5 oxfmt, oxlint: Update logo (#18242) (Dunqing)

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

Labels

A-linter Area - Linter 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