Skip to content

feat(minifier): fold constants if the folded expression is shorter than the original one#9008

Closed
sapphi-red wants to merge 2 commits intomainfrom
02-10-feat_minifier_fold_constants_if_the_folded_expression_is_shorter_than_the_original_one
Closed

feat(minifier): fold constants if the folded expression is shorter than the original one#9008
sapphi-red wants to merge 2 commits intomainfrom
02-10-feat_minifier_fold_constants_if_the_folded_expression_is_shorter_than_the_original_one

Conversation

@sapphi-red
Copy link
Member

No description provided.

Copy link
Member Author

sapphi-red commented Feb 10, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Boshen
Copy link
Member

Boshen commented Feb 10, 2025

Can you move this out of the stack so I can merge the other PRs first? This PR is interesting ;-)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2025

CodSpeed Performance Report

Merging #9008 will degrade performances by 87.02%

Comparing 02-10-feat_minifier_fold_constants_if_the_folded_expression_is_shorter_than_the_original_one (1857746) with main (81bed37)

Summary

❌ 3 regressions
✅ 30 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
minifier[antd.js] 159.8 ms 1,230.9 ms -87.02%
minifier[react.development.js] 1.6 ms 9.9 ms -83.65%
minifier[typescript.js] 275.1 ms 1,326.2 ms -79.26%

@Boshen
Copy link
Member

Boshen commented Feb 10, 2025

I knew it!

Merging #9008 will degrade performances by 87.02%

@github-actions github-actions bot added the A-codegen Area - Code Generation label Feb 10, 2025
p.add_source_mapping(self.span);
let last = p.last_byte();
let pattern_text = self.regex.pattern.source_text(p.source_text);
let pattern_text = self.regex.pattern.to_string();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm not calling CodeGen::build in count_char_when_printing, self.regex.pattern.source_text(p.source_text) errors due to CodeGen::source_text being an empty string.

let mut cg = Codegen::new()
    .with_options(CodegenOptions { minify: true, ..CodegenOptions::default() });
cg.print_expression(expr);
cg.into_source_text().len()

@Boshen
Copy link
Member

Boshen commented Feb 20, 2025

Let's reconsider this approach once we stabilize the minifier.

@Boshen Boshen closed this Feb 20, 2025
@sapphi-red sapphi-red deleted the 02-10-feat_minifier_fold_constants_if_the_folded_expression_is_shorter_than_the_original_one branch August 13, 2025 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation A-minifier Area - Minifier C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants