Skip to content

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Oct 17, 2025

Large phf_map! calls can be worth the cost, but small ones are probably not worth it. Profiling showed that a number of these small maps add some constant overhead when linting, so I've replaced them with some simple match calls.

Copy link
Member Author

camchenry commented Oct 17, 2025


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-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance labels Oct 17, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 17, 2025

CodSpeed Performance Report

Merging #14701 will improve performances by 4%

Comparing 10-16-perf_linter_remove_simple_phf_map_calls (b42a79f) with main (c6395c7)1

Summary

⚡ 1 improvement
✅ 3 untouched
⏩ 33 skipped2

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Instrumentation linter[RadixUIAdoptionSection.jsx] 863.3 µs 830.1 µs +4%

Footnotes

  1. No successful run was found on main (cd266b4) during the generation of this report, so c6395c7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 33 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 self-assigned this Oct 17, 2025
@camchenry camchenry force-pushed the 10-16-perf_linter_remove_simple_phf_map_calls branch from a55ef9e to b42a79f Compare October 18, 2025 23:16
@camchenry camchenry marked this pull request as ready for review October 19, 2025 01:07
@camchenry camchenry requested a review from camc314 as a code owner October 19, 2025 01:07
Copilot AI review requested due to automatic review settings October 19, 2025 01:07
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

Replaces several small phf_map! constant maps with direct match-based lookup functions to reduce constant overhead and improve linting performance.

  • Removes phf dependencies in multiple lint rule files, introducing simple helper lookup functions.
  • Adjusts call sites to use Option-returning lookup functions instead of iterating map entries.
  • Refactors plugin name prefix resolution from a static map to a match expression.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
prefer_query_selector.rs Replaced small identifier map with get_preferred_identifier_name match function and updated diagnostic/fixer usage.
prefer_modern_dom_apis.rs Converted two small maps (methods and positions) to match-based lookup helpers.
prefer_tag_over_role.rs Replaced role→tag map with get_tags_from_role; simplified role checking logic.
no_redundant_roles.rs Replaced default role exceptions map with get_default_role_exception helper.
aria_props.rs Replaced common ARIA typos map with get_common_aria_prop_typo helper.
no_deprecated_functions.rs Converted deprecated function map to deprecated_functions_map lookup function; updated fix application.
prefer_numeric_literals.rs Replaced radix ordered set map with radix_map returning a tuple (name, prefix).
context/mod.rs Removed PLUGIN_PREFIXES map and implemented plugin_name_to_prefix via match; eliminated associated comment.
Comments suppressed due to low confidence (1)

crates/oxc_linter/src/context/mod.rs:1

  • Previously there was a doc comment explaining this mapping; after inlining with match it was removed. Add a brief doc comment above plugin_name_to_prefix to clarify that it normalizes short plugin identifiers to their fully prefixed names.
#![expect(rustdoc::private_intra_doc_links)] // useful for intellisense

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Boshen
Copy link
Member

Boshen commented Oct 19, 2025

NICE!

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Oct 19, 2025
Copy link
Member

Boshen commented Oct 19, 2025

Merge activity

Large `phf_map!` calls can be worth the cost, but small ones are probably not worth it. Profiling showed that a number of these small maps add some constant overhead when linting, so I've replaced them with some simple match calls.
@graphite-app graphite-app bot force-pushed the 10-16-perf_linter_remove_simple_phf_map_calls branch from b42a79f to 86ecae1 Compare October 19, 2025 07:46
@graphite-app graphite-app bot merged commit 86ecae1 into main Oct 19, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 10-16-perf_linter_remove_simple_phf_map_calls branch October 19, 2025 07:50
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 19, 2025
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.

4 participants