Much Slower Performance After Migrating To This Plugin
Ein zugehöriger Pull Request wurde bereits gemerged.
- #375 von @alexander-akait — gemerged
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- eslint, javascript, typescript, webpack
- Bereich
- performance, tooling
Rechercherichtung
Start with the provided bench.js benchmark and webpack.config.js variants, then compare the diagnostics-webpack-plugin and eslint-webpack-plugin runs using the supplied package versions and environment. Identify what accounts for the roughly 2× slowdown, including the reported change between plugin versions 1.0.1 and 1.0.2. Done means the cause is isolated and the benchmark results support a performance fix; a linked merged pull request indicates the work has already moved forward.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Have you used AI?
Yes
Bug Description
I just migrated to diagnostics-webpack-plugin from eslint. It is way slower with this plugin even with only eslint plugin. The build times were around 80 seconds, now they are around 240 seconds, making it 3x slower. Here is a simple version I created to prove this problem:
Without threads config and threads: false we get similar results, with a little faster results without threads: false config.
When you run npm run bench after installing packages, here are the results:
> npm run bench
> bench
> node bench.js
Generated components in src/
run 1/10 asis-nothreads 21.68s
run 1/10 legacy 18.98s
run 2/10 asis-nothreads 17.45s
run 2/10 legacy 9.62s
run 3/10 asis-nothreads 17.42s
run 3/10 legacy 9.65s
run 4/10 asis-nothreads 17.80s
run 4/10 legacy 9.72s
run 5/10 asis-nothreads 20.20s
run 5/10 legacy 10.39s
run 6/10 asis-nothreads 18.21s
run 6/10 legacy 9.89s
run 7/10 asis-nothreads 17.73s
run 7/10 legacy 10.28s
run 8/10 asis-nothreads 17.61s
run 8/10 legacy 10.23s
run 9/10 asis-nothreads 24.08s
run 9/10 legacy 12.47s
run 10/10 asis-nothreads 22.00s
run 10/10 legacy 12.94s
Average of 10 runs:
asis-nothreads 19.42s (17.42-24.08)
legacy 11.42s (9.62-18.98)
Link to Minimal Reproduction and step to reproduce
Here are the files in the example repo:
===== bench.js =====
const { spawnSync } = require('node:child_process');
const fs = require('node:fs');
fs.rmSync('src', { recursive: true, force: true });
fs.mkdirSync('src');
const lines = [];
for (let i = 0; i < 1000; i++) {
fs.writeFileSync(`src/shared-${i}.tsx`, `export const Shared${i} = 1;\n`);
lines.push(`export { Shared${i} } from './shared-${i}';`);
}
fs.writeFileSync('src/index.tsx', lines.join('\n') + '\n');
console.log(`Generated components in src/`);
const VARIANTS = ['asis-nothreads', 'legacy'];
const webpack = require.resolve('webpack-cli/bin/cli.js');
const times = Object.fromEntries(VARIANTS.map(v => [v, []]));
for (let run = 1; run <= 10; run++) {
for (const variant of VARIANTS) {
const start = performance.now();
spawnSync(process.execPath, [webpack, '--env', `variant=${variant}`], { encoding: 'utf8' });
const seconds = (performance.now() - start) / 1000;
times[variant].push(seconds);
console.log(`run ${run}/10 ${variant.padEnd(16)} ${seconds.toFixed(2)}s`);
}
}
console.log('\nAverage of 10 runs:');
for (const v of VARIANTS) {
const avg = times[v].reduce((a, b) => a + b, 0) / times[v].length;
console.log(`${v.padEnd(16)} ${avg.toFixed(2)}s (${Math.min(...times[v]).toFixed(2)}-${Math.max(...times[v]).toFixed(2)})`);
}
===== eslint.config.mjs =====
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
export default [{
files: ['**/*.tsx'],
plugins: { '@typescript-eslint': typescriptEslint },
languageOptions: {
parser: tsParser,
parserOptions: { project: ['tsconfig.json'] },
},
rules: {
'@typescript-eslint/naming-convention': ['error', { selector: ['class', 'interface'], format: ['PascalCase'] }],
},
}];
===== package.json =====
{
"devDependencies": {
"@typescript-eslint/eslint-plugin": "8.72.0",
"@typescript-eslint/parser": "8.72.0",
"diagnostics-webpack-plugin": "1.0.2",
"eslint": "10.13.0",
"eslint-webpack-plugin": "6.0.0",
"ts-loader": "9.6.2",
"typescript": "6.0.3",
"webpack": "5.112.0",
"webpack-cli": "7.2.3"
},
"scripts": {
"bench": "node bench.js"
}
}
===== tsconfig.json =====
{
"compilerOptions":{
"jsx": "react-jsx"
}
}
===== webpack.config.js =====
const DiagnosticsPlugin = require('diagnostics-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const variants = {
'asis-nothreads': () => new DiagnosticsPlugin({ threads: false, checks: [{ use: 'eslint', extensions: ['tsx'] }] }),
'legacy': () => new ESLintPlugin({ extensions: ['tsx'] }),
};
module.exports = env => ({
entry: './src/index.tsx',
resolve: { extensions: ['.tsx'] },
module: { rules: [{ test: /\.tsx$/, loader: 'ts-loader', options: { transpileOnly: true } }] },
plugins: [variants[env.variant]()],
});
Expected Behavior
I would expect it to be the same speed
Actual Behavior
It is 2x slower than eslint plugin
Environment
Windows 11
32 GB memory
AMD Ryzen 7 Pro
Node version 24.15.0
npm version: 11.18.0
"webpack": "5.112.0",
Is this a regression?
No
Last Working Version
1.0.2
Additional Context
It was slow in version 1.0.1 but it is even slower in version 1.0.2
- Vorherrschende Sprache
- JavaScript
- Sterne
- 259
- Forks
- 47
- Ø Merge
- 6 Std. 22 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Ähnliche Issues
-
Mend: dependency security vulnerability
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
ManageIQ/manageiq-ui-service#2259 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
electerious/Ackee#411 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
[bug] 提瓦特记事本原石检测框宽度较窄Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
babalae/bettergi-scripts-list#3905 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 87/100
dedicatedcode/reitti#1445 ·
Maintainer antworten meist innerhalb von 1 Tag