-
-
Notifications
You must be signed in to change notification settings - Fork 488
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(linter): move shared context info to ContextHost
#5795
perf(linter): move shared context info to ContextHost
#5795
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #5795 will not alter performanceComparing Summary
|
c16515a
to
ecaa30e
Compare
Merge activity
|
> Related to #5770 ## What This PR Does Moves state that is constant over a linted file out of `LintContext` and into a shared `ContextHost` struct, turning `LintContext` into a [flyweight](https://en.wikipedia.org/wiki/Flyweight_pattern). This brings `LintContext` from 144 bytes down to 96. `Linter::run` iterates over `(rule, ctx)` pairs in a very tight loop, and each rule instance gets its own clone of `ctx`. A smaller `LintContext` means better cache locality and a smaller heap allocation for this vec. I'm hoping to eventually get it small enough to fit in a single cache line. I made a PR a while ago that did something similar to this one, but instead of using an `Rc`, each `LintContext` stored a read-only reference. This added an extra lifetime parameter, making it slightly unwieldy, but I saw up to 15%/25% perf improvements on local benchmarks. I'll dig around for it and add a link shortly. ### Architecture ![image](https://github.com/user-attachments/assets/9e8352ae-a581-46a3-a578-9eb855d4ebaf) ---- ![image](https://github.com/user-attachments/assets/49213cd9-3c31-40dc-97ad-ddf010705ab6)
ecaa30e
to
e413cad
Compare
## [0.9.6] - 2024-09-18 ### Features - 3bf7b24 linter: Make `typescript/no-duplicate-enum-values` a `correctness` rule (#5810) (DonIsaac) - 7799c06 linter/react: Implement `no-danger-with-children` rule (#5420) (Cam McHenry) ### Bug Fixes - f942485 linter: Remove all* remaining "Disallow <foo>" messages (#5812) (DonIsaac) - b5ad518 linter: Improve diagnostic messages for various lint rules (#5808) (DonIsaac) - 858f7af linter: Plugin prefix name for eslint-plugin-node (#5807) (DonIsaac) - 737ba1d linter: Fix some cases on ```AssignmentExpression``` for ```unicorn/consistent-function-scoping``` (#5675) (Arian94) - 148c7a8 linter: Replace bitwise AND (&) with logical AND (&&) in explici… (#5780) (kaykdm) - b4ed564 linter/no-unused-vars: Writes to members triggering false positive (#5744) (Dunqing) - e9c084a linter/no-unused-vars: False positive when a variable used as a computed member property (#5722) (Dunqing) ### Performance - 3725d5d linter: Make all rules share a diagnostics vec (#5806) (DonIsaac) - e978567 linter: Shrink size of `DisableDirectives` (#5798) (DonIsaac) - 1bfa515 linter: Remove redundant clone of diagnostics in context (#5797) (DonIsaac) - e413cad linter: Move shared context info to `ContextHost` (#5795) (DonIsaac) ### Refactor - 6dd6f7c ast: Change `Comment` struct (#5783) (Boshen) - 7caae5b codegen: Add `GetSpan` requirement to `Gen` trait (#5772) (Boshen) - 026ee6a linter: Decouple module resolution from import plugin (#5829) (dalaoshu) - 50834bc linter: Move `override_rule` to `OxlintRules` (#5708) (DonIsaac) - a438743 linter: Move `OxlintConfig` to `Oxlintrc` (#5707) (DonIsaac) - f61e8b5 linter: Impl serde and schemars traits for `LintPlugins` (#5706) (DonIsaac) - 20a7861 linter: Shorten `Option` syntax (#5735) (overlookmotel) - d8b612c oxc_linter: Prefer pass Enum instead of str `no_plus_plus` (#5730) (IWANABETHATGUY) - cc0408b semantic: S/AstNodeId/NodeId (#5740) (Boshen) --------- Co-authored-by: Boshen <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
What This PR Does
Moves state that is constant over a linted file out of
LintContext
and into a sharedContextHost
struct, turningLintContext
into a flyweight.This brings
LintContext
from 144 bytes down to 96.Linter::run
iterates over(rule, ctx)
pairs in a very tight loop, and each rule instance gets its own clone ofctx
. A smallerLintContext
means better cache locality and a smaller heap allocation for this vec. I'm hoping to eventually get it small enough to fit in a single cache line.I made a PR a while ago that did something similar to this one, but instead of using an
Rc
, eachLintContext
stored a read-only reference. This added an extra lifetime parameter, making it slightly unwieldy, but I saw up to 15%/25% perf improvements on local benchmarks. I'll dig around for it and add a link shortly.Architecture