From 47ea8de2777051bce249f666b10580f168d8d72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 20 Jan 2025 01:37:55 +0900 Subject: [PATCH] perf(es/minifier): Adjust threshold for parallel char frequency calculation (#9901) --- .changeset/warm-tigers-approve.md | 6 ++++++ crates/swc_ecma_minifier/src/util/base54.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .changeset/warm-tigers-approve.md diff --git a/.changeset/warm-tigers-approve.md b/.changeset/warm-tigers-approve.md new file mode 100644 index 000000000000..1a9545ca6d45 --- /dev/null +++ b/.changeset/warm-tigers-approve.md @@ -0,0 +1,6 @@ +--- +swc_core: patch +swc_ecma_minifier: patch +--- + +perf(es/minifier): Adjust threshold for parallel char frequency calculation diff --git a/crates/swc_ecma_minifier/src/util/base54.rs b/crates/swc_ecma_minifier/src/util/base54.rs index 5e469b2a3d36..56f2eeec4a16 100644 --- a/crates/swc_ecma_minifier/src/util/base54.rs +++ b/crates/swc_ecma_minifier/src/util/base54.rs @@ -327,19 +327,19 @@ impl Visit for CharFreqAnalyzer<'_> { visit_obj_and_computed!(); fn visit_class_members(&mut self, members: &[ClassMember]) { - self.maybe_par(cpu_count(), members, |v, member| { + self.maybe_par(cpu_count() * 8, members, |v, member| { member.visit_with(v); }); } fn visit_expr_or_spreads(&mut self, n: &[ExprOrSpread]) { - self.maybe_par(cpu_count(), n, |v, n| { + self.maybe_par(cpu_count() * 8, n, |v, n| { n.visit_with(v); }); } fn visit_exprs(&mut self, exprs: &[Box]) { - self.maybe_par(cpu_count(), exprs, |v, expr| { + self.maybe_par(cpu_count() * 8, exprs, |v, expr| { expr.visit_with(v); }); } @@ -361,13 +361,13 @@ impl Visit for CharFreqAnalyzer<'_> { fn visit_module_export_name(&mut self, _: &ModuleExportName) {} fn visit_module_items(&mut self, items: &[ModuleItem]) { - self.maybe_par(cpu_count(), items, |v, item| { + self.maybe_par(cpu_count() * 8, items, |v, item| { item.visit_with(v); }); } fn visit_opt_vec_expr_or_spreads(&mut self, n: &[Option]) { - self.maybe_par(cpu_count(), n, |v, n| { + self.maybe_par(cpu_count() * 8, n, |v, n| { n.visit_with(v); }); } @@ -383,13 +383,13 @@ impl Visit for CharFreqAnalyzer<'_> { } fn visit_prop_or_spreads(&mut self, n: &[PropOrSpread]) { - self.maybe_par(cpu_count(), n, |v, n| { + self.maybe_par(cpu_count() * 8, n, |v, n| { n.visit_with(v); }); } fn visit_stmts(&mut self, stmts: &[Stmt]) { - self.maybe_par(cpu_count(), stmts, |v, stmt| { + self.maybe_par(cpu_count() * 8, stmts, |v, stmt| { stmt.visit_with(v); }); }