Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance MagicString#indent #9

Open
hyf0 opened this issue Nov 16, 2023 · 0 comments
Open

Improve performance MagicString#indent #9

hyf0 opened this issue Nov 16, 2023 · 0 comments

Comments

@hyf0
Copy link
Member

hyf0 commented Nov 16, 2023

MagicString#indent was incredibly slow before 4515818.

Now I think it's sill slow unexpectedly. Should do something about it.

hyf0 added a commit to rolldown/rolldown that referenced this issue Nov 17, 2023
<!-- Thank you for contributing! -->

### Description

rolldown/string_wizard#9

The problem is that bundling cjs module requre calling `MagicString#indent`, which was incredibly slow due to lacking of optimization: rolldown/string_wizard@4515818.


```
┌─────────┬────────────────────┬─────────┬───────────────────┬───────────┬─────────┐
│ (index) │     Task Name      │ ops/sec │ Average Time (ns) │  Margin   │ Samples │
├─────────┼────────────────────┼─────────┼───────────────────┼───────────┼─────────┤
│    0    │ 'rolldown-threejs' │  '109'  │ 9110844.725912267 │ '±10.05%' │   11    │
│    1    │ 'esbuild-threejs'  │  '52'   │ 19223512.59738207 │ '±13.03%' │   10    │
└─────────┴────────────────────┴─────────┴───────────────────┴───────────┴─────────┘
┌─────────┬───────────────────────┬─────────┬────────────────────┬───────────┬─────────┐
│ (index) │       Task Name       │ ops/sec │ Average Time (ns)  │  Margin   │ Samples │
├─────────┼───────────────────────┼─────────┼────────────────────┼───────────┼─────────┤
│    0    │ 'rolldown-threejs10x' │   '9'   │ 102347845.79873085 │ '±10.12%' │   10    │
│    1    │ 'esbuild-threejs10x'  │   '5'   │ 166986120.80067396 │ '±3.19%'  │   10    │
└─────────┴───────────────────────┴─────────┴────────────────────┴───────────┴─────────┘
┌─────────┬────────────────────────────────┬─────────┬────────────────────┬──────────┬─────────┐
│ (index) │           Task Name            │ ops/sec │ Average Time (ns)  │  Margin  │ Samples │
├─────────┼────────────────────────────────┼─────────┼────────────────────┼──────────┼─────────┤
│    0    │ 'rolldown-react_and_react_dom' │  '49'   │ 20094408.302009106 │ '±5.22%' │   10    │
│    1    │ 'esbuild-react_and_react_dom'  │  '45'   │ 21785495.999455452 │ '±3.87%' │   10    │
└─────────┴────────────────────────────────┴─────────┴────────────────────┴──────────┴─────────┘
```

<!-- Please insert your description here and provide especially info about the "what" this PR is solving -->

### Test Plan

<!-- e.g. is there anything you'd like reviewers to focus on? -->

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant