Skip to content

Conversation

@arendjr
Copy link
Contributor

@arendjr arendjr commented Jun 20, 2025

Summary

This PR implements 3 different performance optimisations, one of which has a large impact on the code, and one of which has a large impact on the performance.

  • First of all, I introduced a small optimisation in the collector. We used to store variable declaration and parameter nodes before doing the local inference on them in one go. Now we parse them as we go. It should be a tiny bit faster, since we have one less vector to keep track of, but it did not make a measurable difference. At least the code is slightly simpler now.
  • Second is the one I named this PR after: The TypeStore now stores all its TypeData instances behind Arcs. To facilitate this, the signatures for TypeData::resolved() and TypeData::flattened() have been updated and both return an Option<TypeData> now, and only when Some instance is returned we create a new Arc for it. This approach saves a significant amount of cloning during the flattening and resolving phases. Moreover, the code became significantly simpler and less scary because types can now be resolved and flattened while they're still part of the store, so there's no need for "take type temporarily" workarounds anymore. All in all, this change made Biome's total running time ~3% faster.
  • But the real winner was the tiniest change: In the ModuleResolver we have a modules_by_path map to quickly find imported modules. It seems the amount of modules we import has become quite considerable, because I was able to achieve a ~30% performance improvement by changing this from a BTreeMap to an FxHashMap.

I have dropped the React snapshot from the tests, since it was creating a lot of noise and the purpose of the snapshot (improving inference from React imports) has been achieved.

Test Plan

Everything should stay green.

@arendjr arendjr requested review from a team June 20, 2025 17:01
@changeset-bot
Copy link

changeset-bot bot commented Jun 20, 2025

⚠️ No Changeset found

Latest commit: 0f332d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jun 20, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 20, 2025

CodSpeed Performance Report

Merging #6442 will create unknown performance changes

Comparing arendjr:arc-type-storage (0f332d0) with next (c8c738e)

Summary

🆕 115 new benchmarks
⁉️ 95 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 deserialize_from_json_str[biome.json] N/A 361.7 µs N/A
🆕 css_analyzer[bootstrap_18416142857265205439.css] N/A 487.6 ms N/A
🆕 css_analyzer[bulma_5641719244145477318.css] N/A 1.1 s N/A
🆕 css_analyzer[foundation_11602414662825430680.css] N/A 177.1 ms N/A
🆕 css_analyzer[pure_9395922602181450299.css] N/A 18.9 ms N/A
🆕 css_analyzer[tachyons_11778168428173736564.css] N/A 133.2 ms N/A
🆕 css_formatter[bootstrap_18416142857265205439.css] N/A 115.7 ms N/A
🆕 css_formatter[bulma_5641719244145477318.css] N/A 366.1 ms N/A
🆕 css_formatter[foundation_11602414662825430680.css] N/A 77 ms N/A
🆕 css_formatter[full_5814491140539129161.css] N/A 1.3 s N/A
🆕 css_formatter[materialize_5526761731747548557.css] N/A 84.1 ms N/A
🆕 css_formatter[pure_9395922602181450299.css] N/A 9.4 ms N/A
🆕 css_formatter[semantic_4685287698740288120.css] N/A 368.5 ms N/A
🆕 css_formatter[tachyons_11778168428173736564.css] N/A 37 ms N/A
🆕 bootstrap_18416142857265205439.css[cached] N/A 35.7 ms N/A
🆕 bootstrap_18416142857265205439.css[uncached] N/A 39.1 ms N/A
🆕 bulma_5641719244145477318.css[cached] N/A 111.7 ms N/A
🆕 bulma_5641719244145477318.css[uncached] N/A 119.3 ms N/A
🆕 foundation_11602414662825430680.css[cached] N/A 23.5 ms N/A
🆕 foundation_11602414662825430680.css[uncached] N/A 24.8 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@github-actions github-actions bot added the A-CLI Area: CLI label Jun 21, 2025
@arendjr arendjr merged commit 7e64920 into biomejs:next Jun 22, 2025
26 of 27 checks passed
@arendjr arendjr added the A-Type-Inference Area: type inference label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter A-Project Area: project A-Type-Inference Area: type inference L-JavaScript Language: JavaScript and super languages

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant