GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — perf(javascript): escape strings, count name characters and find node tokens with less work by alexander-akait · Pull Request #23051 · webpack/webpack Conversation
|
| before | after | |
|---|---|---|
| instructions per minify, three.js (callgrind, CodSpeed flags) | 8,106.9M | 8,043.1M (−0.79%) |
| instructions per minify, lodash | 4,222.9M | 4,205.9M (−0.40%) |
| allocated, lodash + three + acorn (sampling) | 41.6 MB | 38.6 MB (−7%) |
| token binary-search steps, three.js | 511K | 373K (−27%) |
Output check: the minify corpora report is unchanged, and 402 node_modules files give the same output under three option sets, including ascii_only and ie8.
No new changeset: the pending "minifies faster" entry covers this.
What kind of change does this PR introduce?
perf
Did you add tests for your changes?
No. Output is unchanged, and the existing printer unit tests cover the changed lines (every escape, ie8, prefixed and separated numbers).
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Claude Code profiled the minifier, made the changes and measured them (callgrind, allocation sampling, corpora and output comparisons). Reviewed by the author.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
String escaping lib/javascript/syntax-printer.js |
The string scan emits escapes as it processes qualifying characters. It handles NUL before a digit, vertical tabs in IE8 mode, and raw tabs according to the ASCII-only setting. |
Token lookup hints lib/javascript/syntax-printer.js |
Token-start lookups use and update a separate saved hint from token-end lookups. |
Printed-name frequency counting lib/javascript/syntax-printer.js |
Frequency counting decodes valid Unicode escapes, counts supported radix-prefixed numbers by their printed decimal forms, and normalizes underscore-separated numbers. |
Suggested labels: area: build-perf, needs: tests
Suggested reviewers: aryanraj45
Change: Refactor
c04a8No merge-blocking issue was established in the printer changes.
Explanation
The title uses the conventional-commit form with type "perf" and scope "javascript". The change matches the type: the PR reduces minifier work through performance changes in string escaping, mangler character counting, and token search. The title names the three areas the objectives describe. The title does not state the branch prefix, so the match to the branch prefix could not be checked from the provided context.
Warning
Some tools did not complete. Review the errors below.
ast-grep timed out on this file
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… tokens with less work A string literal is escaped in the pass that counts its quotes, where a regexp called a function per escape, and a tab written raw is no longer escaped to be unescaped again. The mangler counts the source's characters once and adjusts for each number it prints in decimal, where it copied the source up to three times. A node's start token is searched from the last start found, where it was searched from its parent's end. Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
b7d8784 to
c04a861
Compare
|
This PR is packaged and the instant preview of its latest commit is available. Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@23051
yarn add -D webpack@https://pkg.pr.new/webpack@23051
pnpm add -D webpack@https://pkg.pr.new/webpack@23051 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Types CoverageTyped lines: 99.50% (165015 of 165851)
Escape hatches count the raw types they stand for too: This pull request adds or removes no escape-hatch type or inferred 120 file(s) in
|
| File | Typed lines | EXPECTED_ANY |
EXPECTED_OBJECT |
EXPECTED_FUNCTION |
unknown |
inferred any |
|---|---|---|---|---|---|---|
lib/javascript/syntax-parser.js |
99.96% | 37 | ||||
declarations/WebpackOptions.ts |
99.94% | 15 | ||||
lib/javascript/syntax-printer.js |
99.94% | 3 | 10 | 2 | ||
lib/Compiler.js |
100.00% | 4 | 3 | 6 | ||
lib/cache/PackFileCacheStrategy.js |
99.23% | 10 | ||||
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% | 3 | 7 | |||
lib/util/cleverMerge.js |
100.00% | 1 | 8 | |||
lib/serialization/ObjectMiddleware.js |
99.79% | 3 | 5 | |||
lib/Compilation.js |
99.69% | 5 | 2 | |||
lib/serialization/SerializerMiddleware.js |
100.00% | 3 | 1 | 3 | ||
lib/util/SourceProcessor.js |
100.00% | 1 | 6 | |||
lib/hmr/HotModuleReplacement.runtime.js |
100.00% | 1 | 5 | |||
lib/resolve/getResolveOptionsKey.js |
100.00% | 1 | 1 | 4 | ||
lib/debug/ProfilingPlugin.js |
100.00% | 1 | 4 | |||
lib/define/DefinePlugin.js |
100.00% | 1 | 4 | |||
lib/loaders/LoaderOptionsPlugin.js |
90.63% | 5 | ||||
lib/module/NormalModule.js |
99.54% | 4 | 1 | |||
lib/cache/MemoryWithGcCachePlugin.js |
100.00% | 4 | ||||
lib/config/normalization.js |
99.14% | 4 | ||||
lib/css/syntax-parser.js |
99.90% | 4 | ||||
lib/graph/ModuleGraph.js |
100.00% | 3 | 1 | |||
lib/html/syntax-parser.js |
99.98% | 4 | ||||
lib/module/Module.js |
99.51% | 4 | ||||
lib/performance/HotspotsPlugin.js |
100.00% | 4 | ||||
lib/util/SortableSet.js |
100.00% | 4 | ||||
lib/cache/MemoryCachePlugin.js |
100.00% | 3 | ||||
lib/stats/StatsFactory.js |
96.99% | 2 | 1 | |||
lib/util/WeakTupleMap.js |
100.00% | 3 | ||||
lib/util/validateSchema.js |
100.00% | 2 | 1 | |||
lib/cache/Cache.js |
100.00% | 2 | ||||
lib/cache/IdleFileCachePlugin.js |
100.00% | 2 | ||||
lib/config/defineConfig.js |
100.00% | 2 | ||||
lib/css/syntax.js |
100.00% | 2 | ||||
lib/html/syntax.js |
100.00% | 2 | ||||
lib/loaders/LoaderRunner.js |
97.70% | 2 | ||||
lib/module/NormalModuleFactory.js |
98.71% | 2 | ||||
lib/module/Parser.js |
100.00% | 2 | ||||
lib/node/nodeConsole.js |
100.00% | 2 | ||||
lib/util/comparators.js |
100.00% | 2 | ||||
lib/util/deprecation.js |
100.00% | 1 | 1 | |||
lib/util/serialization.js |
98.68% | 2 | ||||
lib/config/cli.js |
99.73% | 1 | ||||
lib/context/ContextModuleFactory.js |
100.00% | 1 | ||||
lib/css/cssMinify.js |
100.00% | 1 | ||||
lib/dependencies/import/ImportParserPlugin.js |
100.00% | 1 | ||||
lib/dll/DllReferencePlugin.js |
100.00% | 1 | ||||
lib/errors/NonErrorEmittedError.js |
100.00% | 1 | ||||
lib/errors/WebpackError.js |
100.00% | 1 | ||||
lib/hmr/HotModuleReplacementPlugin.js |
100.00% | 1 | ||||
lib/html/HtmlModulesPlugin.js |
99.51% | 1 | ||||
lib/index.js |
100.00% | 1 | ||||
lib/javascript/JavascriptParser.js |
100.00% | 1 | ||||
lib/javascript/jsMinify.js |
100.00% | 1 | ||||
lib/javascript/syntax.js |
100.00% | 1 | ||||
lib/logging/Logger.js |
100.00% | 1 | ||||
lib/optimize/ConcatenatedModule.js |
99.89% | 1 | ||||
lib/optimize/TupleQueue.js |
100.00% | 1 | ||||
lib/output/CopyPlugin.js |
100.00% | 1 | ||||
lib/output/ManifestPlugin.js |
100.00% | 1 | ||||
lib/rules/BasicEffectRulePlugin.js |
100.00% | 1 | ||||
lib/rules/RuleSetCompiler.js |
99.73% | 1 | ||||
lib/serialization/PlainObjectSerializer.js |
100.00% | 1 | ||||
lib/serialization/Serializer.js |
100.00% | 1 | ||||
lib/serialization/SingleItemMiddleware.js |
100.00% | 1 | ||||
lib/serialization/types.js |
100.00% | 1 | ||||
lib/stats/DefaultStatsFactoryPlugin.js |
99.87% | 1 | ||||
lib/stats/DefaultStatsPresetPlugin.js |
100.00% | 1 | ||||
lib/stats/StatsPrinter.js |
99.11% | 1 | ||||
lib/template/Template.js |
100.00% | 1 | ||||
lib/util/TupleSet.js |
100.00% | 1 | ||||
lib/util/identifier.js |
100.00% | 1 | ||||
lib/util/magicComment.js |
100.00% | 1 | ||||
lib/util/makeSerializable.js |
100.00% | 1 | ||||
lib/util/terminalColors.js |
100.00% | 1 | ||||
lib/MultiCompiler.js |
99.74% | |||||
lib/asset/AssetBytesParser.js |
91.67% | |||||
lib/asset/AssetModulesPlugin.js |
99.38% | |||||
lib/asset/AssetParser.js |
96.15% | |||||
lib/asset/AssetSourceParser.js |
91.67% | |||||
lib/config/validateSchema.js |
94.67% | |||||
lib/css/CssGenerator.js |
99.65% | |||||
lib/css/conventions.js |
98.68% | |||||
lib/css/syntax-printer.js |
99.73% | |||||
lib/dependencies/amd/AMDPlugin.js |
99.31% | |||||
lib/dependencies/amd/AMDRuntimeModules.js |
95.45% | |||||
lib/dependencies/commonjs/CommonJsExportsParserPlugin.js |
99.79% | |||||
lib/dependencies/esm/ESMExportInitFragment.js |
99.35% | |||||
lib/dependencies/html/HtmlEntryDependency.js |
99.83% | |||||
lib/dependencies/import-meta/ImportMetaPlugin.js |
99.63% | |||||
lib/devtool/ModuleFilenameHelpers.js |
99.47% | |||||
lib/devtool/SourceMapDevToolPlugin.js |
99.78% | |||||
lib/errors/CacheEffectivenessWarning.js |
93.75% | |||||
lib/externals/ExternalModule.js |
99.87% | |||||
lib/fs/FileSystemInfo.js |
99.96% | |||||
lib/hmr/HotModuleReplacementChunkVersionCheckRuntimeModule.js |
87.50% | |||||
lib/hmr/HotModuleReplacementRuntimeModule.js |
77.78% | |||||
lib/hmr/JavascriptHotModuleReplacementHelper.js |
91.30% | |||||
lib/hmr/lazyCompilationBackend.js |
99.07% | |||||
lib/html/HtmlGenerator.js |
99.87% | |||||
lib/javascript/JavascriptMetaInfoPlugin.js |
98.08% | |||||
lib/json/JsonParser.js |
96.88% | |||||
lib/loaders/LoaderPlugin.js |
99.41% | |||||
lib/logging/createConsoleLogger.js |
99.00% | |||||
lib/optimize/LazyBucketSortedSet.js |
96.85% | |||||
lib/optimize/SideEffectsFlagPlugin.js |
99.78% | |||||
lib/performance/UnusedDefinesPlugin.js |
96.97% | |||||
lib/performance/UnusedExternalsPlugin.js |
95.35% | |||||
lib/runtime/MakeDeferredNamespaceObjectRuntime.js |
99.65% | |||||
lib/schemes/HttpUriPlugin.js |
99.87% | |||||
lib/serialization/BinaryMiddleware.js |
99.27% | |||||
lib/sharing/semver.js |
99.54% | |||||
lib/stats/DefaultStatsPrinterPlugin.js |
99.88% | |||||
lib/template/RuntimeTemplate.js |
99.95% | |||||
lib/util/async.js |
97.62% | |||||
lib/util/createMappings.js |
98.45% | |||||
lib/util/globUtils.js |
99.83% | |||||
lib/util/registerExternalSerializer.js |
96.85% | |||||
lib/wasm-sync/WebAssemblyParser.js |
98.94% | |||||
lib/wasm/AsyncWebAssemblyParser.js |
97.83% | |||||
lib/webpack.js |
98.62% |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Generated code sizeComparing base (
Read Sample appsNo sample app changed size. 26 unchanged app(s)
No asset changed size. No runtime gained or lost a runtime module. Built |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Merging this PR will improve performance by ×562 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The printer's format options are camelCase since #23052, so the check #23051 added read an option that is never set, and ASCII-only output escaped the tabs of a long string it would otherwise write raw. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
* refactor(types): drop casts through unknown the target type accepts A node the tree writes is already the `NodeOf` type a parse method returns, the generated `NodeType` already fits `TreeTypeCodes`, an `IdentifierNode` is an `Identifier`, and the HTML tokenizer's token is a `Token`. Casting through `unknown` hid nothing there; the casts left still cross between a tree handle and a node. * refactor: type minify options, print options and CSS edit keys Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * refactor: drop redundant MinifyOptions cast Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * refactor(types): type memo cache keys, stats filters and hook instances Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * chore: add changeset for memo cache key types Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * fix(types): default the new memo cache type parameters Calls that pass only the type arguments provide and cachedProvide had before keep compiling. The type generator now prints a type parameter named in another's constraint or default as a reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * chore: shorten the memo cache changeset Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh * fix(javascript): read asciiOnly where a string's tabs are written raw The printer's format options are camelCase since #23052, so the check #23051 added read an option that is never set, and ASCII-only output escaped the tabs of a long string it would otherwise write raw. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.