perf: MCP/Skills auto improvements#2
Open
art049 wants to merge 5 commits into
Open
Conversation
Merging this PR will improve performance by 16.03%
Performance Changes
Comparing |
…ant AST walks Replace iterator-chain-based QualifiedName construction with direct slice concatenation via new `from_two_parts` method, and add a fast path for simple name expressions (no attribute access) that skips UnqualifiedName::from_expr entirely. Walltime improvements: 1.3-3.3% across all-rules linter benchmarks. Co-Authored-By: CodSpeed <no-reply@codspeed.io>
Two optimizations for the resolve_qualified_name hot path: 1. from_two_parts: directly construct inline SegmentsStack for the common case (≤8 segments), bypassing the SegmentsVec API overhead (match on variant, capacity checks, spill handling on each extend_from_slice). 2. resolve_qualified_name: extract attribute tail segments directly from the AST for single and double attribute access (e.g., os.path, os.path.join), avoiding the cost of UnqualifiedName::from_expr entirely for these common cases. Walltime benchmarks show -4.3% to -5.5% improvement on large files. Co-Authored-By: CodSpeed <no-reply@codspeed.io>
Two optimizations targeting physical line processing: 1. bidirectional_unicode: Skip the contains() check for ASCII-only lines, since all bidirectional Unicode characters are non-ASCII. The is_ascii() check is SIMD-accelerated and handles the common case immediately. 2. LineWidthBuilder::add_str: For ASCII text, iterate bytes directly instead of chars, avoiding per-character unicode_width lookups. ASCII characters always have width 1 (except tabs and newlines which are handled explicitly). Walltime benchmarks show -1% to -3% additional improvement across all test files, with the largest gains on large/dataset.py. Co-Authored-By: CodSpeed <no-reply@codspeed.io>
- Add super-fast path in `add_str` using `memchr3` to skip byte-by-byte iteration for ASCII text without tabs/newlines/CR (just add byte length) - Add tighter early exit in `Overlong::try_from_line`: for any text, display width ≤ UTF-8 byte length (except tabs), so lines with byte length ≤ limit and no tabs cannot be overlong - Hoist `indented_form_feed` rule check outside the per-line loop in `check_physical_lines` Co-Authored-By: CodSpeed <no-reply@codspeed.io>
cf1bdf5 to
c720d4e
Compare
- Pre-allocate nodes, bindings, references, branches, scopes, and definitions in SemanticModel based on estimated token count - Pre-allocate resolved_names and shadowed_bindings FxHashMaps - Pre-allocate global scope bindings map (256 slots for Python builtins) - Add Scopes::with_capacity and Definitions::for_module_with_capacity - Pre-allocate deferred visit (functions) and analyze (scopes) Vecs - Cache ambiguous unicode confusable settings check outside loop Co-Authored-By: CodSpeed <no-reply@codspeed.io>
c720d4e to
c85edb8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test Plan