Skip to content

fix: improve performance in many places#199

Merged
alexander-akait merged 1 commit intomainfrom
fix-perf
Apr 22, 2026
Merged

fix: improve performance in many places#199
alexander-akait merged 1 commit intomainfrom
fix-perf

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Summary

What kind of change does this PR introduce?

Did you add tests for your changes?

Does this PR introduce a breaking change?

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: dbcf1df

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 96.46018% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.87%. Comparing base (2081a31) to head (dbcf1df).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/OriginalSource.js 95.23% 1 Missing ⚠️
lib/RawSource.js 94.44% 1 Missing ⚠️
lib/SourceMapSource.js 83.33% 1 Missing ⚠️
lib/helpers/streamChunksOfRawSource.js 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
- Coverage   98.07%   97.87%   -0.20%     
==========================================
  Files          25       25              
  Lines        1866     1884      +18     
  Branches      596      595       -1     
==========================================
+ Hits         1830     1844      +14     
- Misses         34       38       +4     
  Partials        2        2              
Flag Coverage Δ
integration 97.87% <96.46%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 21, 2026

Merging this PR will degrade performance by 17.31%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 38 improved benchmarks
❌ 2 regressed benchmarks
✅ 107 untouched benchmarks

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

Performance Changes

Benchmark BASE HEAD Efficiency
concat-source: map() 23 ms 19.6 ms +17.54%
helpers/createMappingsSerializer: lines-only serializer 2.8 ms 2.5 ms +11.66%
helpers/createMappingsSerializer: full serializer 4.5 ms 3.8 ms +18.54%
helpers/getGeneratedSourceInfo: fixture 30.3 ms 9.7 ms ×3.1
concat-source: size() 205.8 µs 117.8 µs +74.79%
cached-source: getCachedData() then restore 20.6 ms 18.3 ms +12.13%
cached-source: new CachedSource() 311.5 µs 346.7 µs -10.15%
helpers/getGeneratedSourceInfo: big source 9.2 ms 2.1 ms ×4.4
cached-source: sourceAndMap() (cold) 20.5 ms 17 ms +20.41%
cached-source: streamChunks() (cold) 11.5 ms 8.8 ms +30.73%
compat-source: wraps OriginalSource 35.3 ms 30.8 ms +14.66%
concat-source: sourceAndMap() 23 ms 19.6 ms +17.48%
helpers/splitIntoLines: big source 10.9 ms 4.8 ms ×2.3
helpers/splitIntoLines: empty 327.2 µs 88.2 µs ×3.7
helpers/splitIntoLines: fixture 41.2 ms 23.9 ms +72.63%
helpers/splitIntoLines: long lines 425.9 ms 2 ms ×210
original-source: sourceAndMap({columns:false}) 7.2 ms 4 ms +77.79%
original-source: streamChunks({columns:false}) 5.3 ms 2.1 ms ×2.6
original-source: size() 2.4 ms 1.1 ms ×2.2
prefix-source: map() 12.2 ms 9.5 ms +28.2%
... ... ... ... ...

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


Comparing fix-perf (dbcf1df) with main (2081a31)

Open in CodSpeed

@alexander-akait alexander-akait merged commit 58420d1 into main Apr 22, 2026
28 of 31 checks passed
@alexander-akait alexander-akait deleted the fix-perf branch April 22, 2026 13:59
alexander-akait pushed a commit that referenced this pull request Apr 22, 2026
The constructors of RawSource, OriginalSource and SourceMapSource
preallocated `this._cachedSize = undefined` so that size() has a stable
hidden-class slot to write to. That made every construction pay for
memoization machinery regardless of whether .size() was ever called,
showing up on CodSpeed as a ~12% regression on
`cached-source: new CachedSource()` and 5-13% on several
`source-map-source: new (*)` benchmarks.

The size() overrides already guard on `this._cachedSize !== undefined`,
which correctly handles missing properties. Drop the eager assignment
and let the field be created on the first size() call. This keeps the
size()/streamChunks() improvements from PR #199 (e.g. ~8x on a one-shot
`new SMS().size()`) while erasing the construction regression.

https://claude.ai/code/session_01LZbaaPrnDTu6y7s4nK4cJz
alexander-akait pushed a commit that referenced this pull request Apr 22, 2026
The constructors of RawSource, OriginalSource and SourceMapSource
preallocated `this._cachedSize = undefined` so that size() has a stable
hidden-class slot to write to. That made every construction pay for
memoization machinery regardless of whether .size() was ever called,
showing up on CodSpeed as a ~12% regression on
`cached-source: new CachedSource()` and 5-13% on several
`source-map-source: new (*)` benchmarks.

The size() overrides already guard on `this._cachedSize !== undefined`,
which correctly handles missing properties. Drop the eager assignment
and let the field be created on the first size() call. This keeps the
size()/streamChunks() improvements from PR #199 (e.g. ~8x on a one-shot
`new SMS().size()`) while erasing the construction regression.

https://claude.ai/code/session_01LZbaaPrnDTu6y7s4nK4cJz
alexander-akait pushed a commit that referenced this pull request Apr 22, 2026
The constructors of RawSource, OriginalSource and SourceMapSource
preallocated `this._cachedSize = undefined` so that size() has a stable
hidden-class slot to write to. That made every construction pay for
memoization machinery regardless of whether .size() was ever called,
showing up on CodSpeed as a ~12% regression on
`cached-source: new CachedSource()` and 5-13% on several
`source-map-source: new (*)` benchmarks.

The size() overrides already guard on `this._cachedSize !== undefined`,
which correctly handles missing properties. Drop the eager assignment
and let the field be created on the first size() call. This keeps the
size()/streamChunks() improvements from PR #199 (e.g. ~8x on a one-shot
`new SMS().size()`) while erasing the construction regression.

https://claude.ai/code/session_01LZbaaPrnDTu6y7s4nK4cJz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant