Skip to content

🐛 Parser performance regression since 2.5.11 with large parenthesized object expressions #11747

Description

@yamaaaaaa31

Environment information

biome rage (2.5.13, standalone reproduction directory)
CLI:
  Version:                      2.5.13
  Color support:                false

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_DISTRIBUTION:                unset
  BIOME_LOG_FILE:                    unset
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  BIOME_BINARY:                      unset
  RUST_BACKTRACE:                    unset
  NO_COLOR:                     1
  TERM:
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false
  HTML full support enabled:    unset

Workspace:
  Open Documents:               0

Compared official macOS ARM64 CLI binaries for 2.5.10, 2.5.11, 2.5.12, and 2.5.13. No plugins or imports are needed for the reproduction.

What happened?

After upgrading Biome from 2.5.10 to 2.5.13, checking generated TypeScript mock files became dramatically slower. The regression is already present in 2.5.11 and also affects format alone.

I reduced the trigger to an arrow function returning a large parenthesized object expression: () => ({ ... }). Changing only this structure to () => { return { ... }; } avoids the slowdown.

Standalone reproduction

  1. In an empty directory, run this Python script to create the configuration and test files. No project dependencies, imports, or plugins are required. foo is just a syntactic placeholder; the files are formatted, not executed.
from pathlib import Path
import json

Path("biome.json").write_text(json.dumps({
    "formatter": {
        "indentStyle": "space",
        "indentWidth": 2,
        "lineWidth": 100
    }
}))

for n in (2000, 4000):
    props = "\n".join(
        f"  field{i}: foo({{ min: 1, max: 10 }}),"
        for i in range(n)
    )
    Path(f"paren-{n}.ts").write_text(
        "const f = () => ({\n" + props + "\n});\n"
    )
    Path(f"block-{n}.ts").write_text(
        "const f = () => {\n  return {\n" + props + "\n  };\n};\n"
    )
  1. Preformat the files with 2.5.10 so formatting differences do not distort the comparison:
pnpm dlx @biomejs/biome@2.5.10 format --write paren-2000.ts paren-4000.ts block-2000.ts block-4000.ts
  1. Compare the versions on the same files:
pnpm dlx @biomejs/biome@2.5.10 format paren-4000.ts
pnpm dlx @biomejs/biome@2.5.13 format paren-4000.ts
pnpm dlx @biomejs/biome@2.5.13 format block-4000.ts

The same regression can be observed with 2.5.11 and 2.5.12. For timing, invoke the installed native CLI directly to exclude package downloads and package-manager startup.

Measured results

Wall-clock seconds, invoking the official native binaries directly with the configuration above. These are individual local measurements, not statistical benchmarks. All completed runs exited successfully. >5 s means the process was terminated after five seconds, not that it completed in five seconds.

Version Parenthesized, 2,000 properties Parenthesized, 4,000 properties Block return, 4,000 properties
2.5.10 0.021 s 0.034 s 0.035 s
2.5.11 1.476 s >5 s 0.034 s
2.5.12 1.483 s >5 s 0.034 s
2.5.13 1.458 s >5 s 0.030 s

In the original approximately 2.4 MB generated file, changing object-return arrow functions to block bodies also restored formatting to roughly 0.1–0.2 seconds on the affected versions. The synthetic reproduction above avoids sharing project-specific source.

Suspected cause (source inspection, not confirmed with a patched build)

#11467 (fix(parse/js): disambiguate parenthesized object expressions), which fixes #11464, appears relevant to the 2.5.10 → 2.5.11 boundary.

The new lookahead for parenthesized object/array expressions calls token_after_parenthesized_group, which advances an offset and repeatedly calls p.nth(offset) until the matching closing parenthesis.

In BufferedLexer::nth_non_trivia, extending lookahead uses self.lookahead_iter().skip(current_length). Repeatedly extending the cache appears to traverse the already-buffered prefix again, potentially making a long scan quadratic.

Relevant sources at the 2.5.11 release commit:

The version boundary and syntax-dependent slowdown are measured observations; the explanation above is a hypothesis from source inspection. This report and investigation were prepared with AI assistance.

Expected result

Formatting and checking large parenthesized object expressions should complete with performance comparable to 2.5.10. The equivalent () => ({ ... }) and () => { return { ... }; } forms should not exhibit this large performance difference.

Ideally, scanning to the matching parenthesis should avoid repeatedly traversing the same buffered token prefix, while preserving the parser correctness fix for #11464.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

  1. added
    S-Needs triage
    on Sep 12, 2026
  2. added theissue type on Sep 12, 2026
  3. added
    S-Needs repro
    on Sep 12, 2026
  4. biome-cookie commented on Sep 12, 2026

    @biome-cookie

    Hello @yamaaaaaa31, please provide a minimal reproduction. You can use one of the following options:

    • Provide a link to our playground, if it's applicable.
    • Provide a link to GitHub repository. To easily create a reproduction, you can use our interactive CLI via npm create @biomejs/biome-reproduction

    Issues marked with S-Needs repro will be closed if they have no activity within 3 days.

  5. removed
    S-Needs triage
    on Sep 12, 2026
  6. yamaaaaaa31 commented on Sep 12, 2026

    @yamaaaaaa31
    Author

    I've created a standalone reproduction using the official reproduction CLI:

    https://github.com/yamaaaaaa31/biome-11747-repro

    To run it:

    git clone https://github.com/yamaaaaaa31/biome-11747-repro.git
    cd biome-11747-repro
    npm ci
    npm run repro

    The script compares Biome 2.5.10 and 2.5.13 using their native binaries directly, with a 5-second timeout per run. All fixtures contain synthetic data; no application dependencies, imports, or plugins are needed.

    On macOS ARM64, the 4,000-property parenthesized object takes approximately 0.03–0.04 seconds with 2.5.10, while 2.5.13 exceeds the 5-second timeout. The equivalent block-return control completes in approximately 0.03 seconds with 2.5.13. All completed runs exit successfully.

    The repository includes the fixtures, generator, benchmark script, and measured results. These are individual local measurements, not statistical benchmarks. Prepared with AI assistance.

  7. ematipico commented on Sep 12, 2026

    @ematipico
    Member

    I was hoping you'd give me a project or something I could work with...

  8. yamaaaaaa31 commented on Sep 12, 2026

    @yamaaaaaa31
    Author

    @ematipico
    Thanks for taking a look. This is my first issue in this repository, so I may have misunderstood what you expected from the reproduction. Could you clarify what’s missing from the project I linked or what you’d like me to change? I’d be happy to update it.

  9. ematipico commented on Sep 12, 2026

    @ematipico
    Member

    You created synthetic data, not a real world example. And that part of the code you mentioned hasn't been changed AFAIK.

    You're more than welcome to look at why it's slower, but I wouldn't put much priority this for now, there are other real bugs with real uses cases from real users :)

  10. added
    S-Help-wanted
    on Sep 12, 2026
  11. yamaaaaaa31 commented on Sep 12, 2026

    @yamaaaaaa31
    Author

    @ematipico
    Thanks for clarifying. I should have explained the real-world context more clearly. We encountered this slowdown in our application when upgrading Biome from 2.5.10 to 2.5.13.
    We use Orval to generate TypeScript API clients, Zod schemas, and MSW mocks from OpenAPI, with Biome formatting the generated output. The slowdown was narrowed down to a generated MSW mock file. I created the synthetic example to isolate the behavior without sharing application-specific details.
    I’ve now added an anonymized copy of an actual generated MSW file to the reproduction repository, preserving its expression structure. Both the original and anonymized versions complete formatting in approximately 0.13 seconds with 2.5.10, but exceed a five-second timeout with 2.5.13 on macOS ARM64. You can reproduce this by running npm ci followed by npm run format in the updated repository.
    The suspected cause remains an unverified hypothesis; I haven’t confirmed it with a patched build. Thank you for taking the time to look into this.

  12. added
    S-Needs triage
    and removed
    S-Help-wanted
    S-Needs repro
    on Sep 12, 2026
  13. ematipico commented on Sep 12, 2026

    @ematipico
    Member

    Lovely, thank you!

  14. ematipico commented on Sep 12, 2026

    @ematipico
    Member

    I could reproduce. thank you.

  15. added
    A-Parser
    L-JavaScript
    S-Bug-confirmed
    and removed
    S-Needs triage
    on Sep 12, 2026
  16. self-assigned this
    on Sep 12, 2026
  17. ematipico commented on Sep 12, 2026

    @ematipico
    Member

    New preview release available for @biomejs/biome.
    Branch: fix/parse-regressoin (#11749)
    Install it using the following command:

    npm i https://pkg.pr.new/biomejs/biome/@biomejs/biome@89887bb13d1c79fcb89a3894139f8d70513ceaf6
  18. yamaaaaaa31 commented on Sep 12, 2026

    @yamaaaaaa31
    Author

    @ematipico

    Thanks for the fix! I tested the preview build against our actual application using our existing Biome configuration and plugins.

    Both biome format . and biome check . passed across all 2,296 files, taking approximately 0.56 seconds and 0.73 seconds respectively—comparable to 2.5.10. With 2.5.13, both commands exceeded a 20-second timeout.

    This confirms that the reported slowdown is resolved in our project. Thank you for looking into this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-ParserL-JavaScriptS-Bug-confirmed

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions