fix: improve performance in many places#199
Conversation
|
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 17.31%
|
3a5fb5d to
dbcf1df
Compare
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
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
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
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