GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve performance of ConcatSource by hccampos · Pull Request #6 · webpack/webpack-sources

Conversation

@hccampos

@hccampos hccampos commented Jan 16, 2017

Copy link
Copy Markdown

This PR replaces .map, .forEach and .reduce in ConcatSource with normal for loops which are much faster (in some tests I made with Node 7, between 30-40 times), even if uglier to look at and to longer to write. Since some of these loops are run a lot of times for large projects, I think it is worth it to optimize them as much as possible.

While I haven't had the chance to look deeper into the rest of webpack, I am pretty sure there are more optimization opportunities like these in places that get executed a lot.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hccampos
replace .map and .forEeach in ConcatSource with for loops for extra p…
6f5dfe0
…erformance
@jsf-clabot

jsf-clabot commented Jan 16, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov-io

codecov-io commented Jan 16, 2017 •
edited by codecov Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Merging #6 into master will increase coverage by 1.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #6      +/-   ##
==========================================
+ Coverage    58.5%   59.61%   +1.11%     
==========================================
  Files          11       11              
  Lines         400      411      +11     
  Branches       60       60              
==========================================
+ Hits          234      245      +11     
  Misses        166      166
Impacted Files Coverage Δ
lib/ConcatSource.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ebc91c...6f5dfe0. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheLarkInn

TheLarkInn commented Jan 16, 2017

Copy link
Copy Markdown
Member

Great observation and thank you for the first time PR on this repo (maybe even org?). Question though, do you have existing profile traces that maybe measure and instrument the performance changes between these?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hccampos

hccampos commented Jan 16, 2017

Copy link
Copy Markdown
Author

@TheLarkInn that was a quick reply. I do have some simple node tests that I quickly wrote as a proof of concept. How are you guys tracking performance in Webpack? Any benchmarks available? It would be great to test changes like these on some large-ish codebase that puts a strain on webpack. The codebase we have at work is heavily bottlenecked by Typescript (it seems) so it is tricky to get insight into whether or not the webpack optimizations have much effect.

Anyway, the PR was mostly intended as an "idea" that we can then try to apply in other parts of webpack in places where it can be determined that the code gets executed often.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheLarkInn

TheLarkInn commented Jan 17, 2017

Copy link
Copy Markdown
Member

We have a benchmarks directory in webpack/webpack. Good place to start at least.

hccampos and quantizor reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bebraw

bebraw commented Mar 7, 2017

Copy link
Copy Markdown

Are you still interested in this? You could do benchmarks in a separate PR first as it's worth doing anyway.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sokra

sokra commented Nov 25, 2017

Copy link
Copy Markdown
Member

merged in #32

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sokra sokra closed this Nov 25, 2017
alexander-akait pushed a commit that referenced this pull request May 14, 2026
@claude
feat: add parsedMap option, post-minifier benchmark, getCachedData test
adbb4f8
Addresses the polish items from the second review of PR #221:

- **#2 post-minifier asset shape benchmark.** New Scenario 3 in
  `benchmark/memory/clear-cache.mjs` constructs the shape webpack
  assets actually present at the PROCESS_ASSETS_STAGE_DEV_TOOLING
  hook: a `CachedSource` wrapping a `SourceMapSource` whose
  `_cachedSource` (bundle string) and `_cachedMaps[{}]` (composed
  map) are populated. 50 chunks: 8.5 MB baseline → 0 MB after
  `clearCache({ maps: true, source: false, recursive: false })`.

- **#3 optional `parsedMap: true` flag** on `ClearCacheOptions`.
  When set, `SourceMapSource.clearCache` drops the parsed object
  forms of `_sourceMapAsObject` and `_innerSourceMapAsObject`
  (heaviest cached representation), but only when a serialized form
  (buffer or string) is also held so data stays recoverable.
  Defaults to `false` to preserve the cheap toString re-hydration
  path described in the comment.

- **#4 `getCachedData()` after `clearCache()` interaction test.**
  Pins the observable shape: buffer + source = undefined, maps
  empty, hash + size preserved when their flags default to false.
  Round-trips through `new CachedSource(source, data)` to confirm
  cleared cached data is still a valid input.

- **#5 "release hint" framing** in the `Source.prototype.clearCache`
  JSDoc. Opens with "clearCache is a memory hint: it never affects
  correctness or output, only how expensive the next read is."

- **#6 dedup correctness test** already lives at
  `test/clearCache.js:251` ("a shared subtree is walked once when
  a `visited` WeakSet is passed") with a negative control at :269.

Tests grow to 25 (was 22). Full suite 89,870/89,870 pass, lint
clean. Benchmark numbers unchanged on Scenarios 1 + 2: 44.7%
heap reduction on unique tasks, 3.6× dedup speedup, 228×
`recursive: false` speedup.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@hccampos @jsf-clabot @codecov-io @TheLarkInn @bebraw @sokra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.