Skip to content

Commit

Permalink
perf(es/minifier): Adjust threshold for parallel char frequency calcu…
Browse files Browse the repository at this point in the history
…lation (#9901)
  • Loading branch information
kdy1 authored Jan 19, 2025
1 parent ed74839 commit 47ea8de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/warm-tigers-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_ecma_minifier: patch
---

perf(es/minifier): Adjust threshold for parallel char frequency calculation
14 changes: 7 additions & 7 deletions crates/swc_ecma_minifier/src/util/base54.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr>]) {
self.maybe_par(cpu_count(), exprs, |v, expr| {
self.maybe_par(cpu_count() * 8, exprs, |v, expr| {
expr.visit_with(v);
});
}
Expand All @@ -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<ExprOrSpread>]) {
self.maybe_par(cpu_count(), n, |v, n| {
self.maybe_par(cpu_count() * 8, n, |v, n| {
n.visit_with(v);
});
}
Expand All @@ -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);
});
}
Expand Down

0 comments on commit 47ea8de

Please sign in to comment.