Closed MichaReiser closed 1 day ago
Comparing smol_str
(c157032) with main
(d107968)
⚡ 1
improvements
✅ 29
untouched benchmarks
Benchmark | main |
smol_str |
Change | |
---|---|---|---|---|
⚡ | linter/default-rules[pydantic/types.py] |
1.9 ms | 1.8 ms | +6.89% |
ruff-ecosystem
results✅ ecosystem check detected no linter changes.
ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
``` warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`: - 'ignore' -> 'lint.ignore' - 'select' -> 'lint.select' - 'unfixable' -> 'lint.unfixable' - 'per-file-ignores' -> 'lint.per-file-ignores' warning: `PGH001` has been remapped to `S307`. warning: `PGH002` has been remapped to `G010`. warning: `PLR1701` has been remapped to `SIM101`. ruff failed Cause: Selection of deprecated rule `E999` is not allowed when preview is enabled. ```
ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)
``` warning: Detected debug build without --no-cache. error: Failed to parse examples/gpt_actions_library/.gpt_action_getting_started.ipynb:11:1:1: Expected an expression error: Failed to parse examples/gpt_actions_library/gpt_action_bigquery.ipynb:13:1:1: Expected an expression ```
ℹ️ ecosystem check encountered format errors. (no format changes; 2 project errors)
ruff format --preview --exclude Packs/ThreatQ/Integrations/ThreatQ/ThreatQ.py
``` warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`: - 'ignore' -> 'lint.ignore' - 'select' -> 'lint.select' - 'unfixable' -> 'lint.unfixable' - 'per-file-ignores' -> 'lint.per-file-ignores' warning: `PGH001` has been remapped to `S307`. warning: `PGH002` has been remapped to `G010`. warning: `PLR1701` has been remapped to `SIM101`. ruff failed Cause: Selection of deprecated rule `E999` is not allowed when preview is enabled. ```
ruff format --preview
``` warning: Detected debug build without --no-cache. error: Failed to parse examples/gpt_actions_library/.gpt_action_getting_started.ipynb:11:1:1: Expected an expression error: Failed to parse examples/gpt_actions_library/gpt_action_bigquery.ipynb:13:1:1: Expected an expression ```
Closing in favor of https://github.com/astral-sh/ruff/pull/12101 which shows the most promising results.
One more time. Trying to use
smol_str
forIdentifier
s to avoid heap allocations for strings shorter than 24 characters.I also expect this to help with
red_knot
where the symbol table can't store string slices for symbol names. Instead, the symbol table clones the identifier name which isO(1)
forsmol_str
.Edit: It should be possible to store a
&Name
in the symbol table, now that salsa supports the&'db
lifetime. That means,O(1)
cloning is not as important anymore.Performance improvement
I think the performance improvement mainly comes from the removed
Box<str>
toString
conversion in the hotparse_name
function. It would be possible to remove that conversion by changingExprName
to store aBox<str>
.For a comparison, https://github.com/astral-sh/ruff/pull/12100 uses a
Box<str>
instead of aSmolStr
. The parser improvements are not as significant. But no linter benchmark regress.General observation:
ExprName
identifierdrop
Name
now requires branching