Open
Conversation
added 6 commits
September 10, 2021 14:48
- by rewriting some "map" functions to for loops
- using "?." syntax instead of ||{} in find
- hoisting regexes & functions
developit
reviewed
Sep 15, 2021
mangle.json
Outdated
| "properties": { | ||
| "regex": "/^_/" | ||
| }, | ||
| "toplevel": true |
developit
reviewed
Sep 15, 2021
mangle.json
Outdated
| }, | ||
| "compress": { | ||
| "reduce_funcs": false, | ||
| "passes": 2 |
There was a problem hiding this comment.
No real reason to limit passes - Terser will stop processing once two subsequent passes result in no change.
Suggested change
| "passes": 2 | |
| "passes": 10 |
Author
There was a problem hiding this comment.
Oh this is very interesting to know, thank you again!
developit
reviewed
Sep 15, 2021
Co-authored-by: @developit
Co-authored-by: @developit Co-authored-by: Jason Miller <developit@users.noreply.github.com>
|
This looks promising, why is it stalled? |
|
Thank you! 🎉 |
Author
There is not much more to optimize on the hot path as far as I can see. |
|
Is there anything we can do about to make these changes mergeable? Seems like this PR got stale for a few months already |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark: Before
Benchmarks
Benchmarks performed on:
small-object
native x 4,193,297 ops/sec ±0.73% (93 runs sampled) fast-json-stringify x 60,026,740 ops/sec ±0.48% (91 runs sampled) slow-json-stringify x 61,442,849 ops/sec ±0.50% (94 runs sampled) # slow-json-stringify is +2.36% fastersmall-array
native x 370,801 ops/sec ±0.52% (94 runs sampled) fast-json-stringify x 448,691 ops/sec ±0.43% (96 runs sampled) slow-json-stringify x 1,331,594 ops/sec ±0.51% (96 runs sampled) # slow-json-stringify is +196.77% fasternested-props-short-text
native x 922,660 ops/sec ±0.46% (95 runs sampled) fast-json-stringify x 4,190,374 ops/sec ±0.68% (94 runs sampled) slow-json-stringify x 13,525,473 ops/sec ±0.56% (92 runs sampled) # slow-json-stringify is +222.77% fastermuch-props-short-text
native x 800,738 ops/sec ±0.38% (94 runs sampled) fast-json-stringify x 1,047,538 ops/sec ±0.40% (95 runs sampled) slow-json-stringify x 3,026,591 ops/sec ±0.97% (88 runs sampled) # slow-json-stringify is +188.92% fastermuch-props-big-text
native x 22,005 ops/sec ±0.68% (92 runs sampled) fast-json-stringify x 20,376 ops/sec ±0.71% (90 runs sampled) slow-json-stringify x 3,392,929 ops/sec ±0.49% (93 runs sampled) # slow-json-stringify is +15318.90% fasterbig-text
native x 274,816 ops/sec ±0.43% (92 runs sampled) fast-json-stringify x 285,642 ops/sec ±0.51% (91 runs sampled) slow-json-stringify x 62,128,675 ops/sec ±0.69% (91 runs sampled) # slow-json-stringify is +21650.61% fasterbig-array-short-text
native x 4,678 ops/sec ±0.47% (93 runs sampled) slow-json-stringify x 11,670 ops/sec ±0.44% (93 runs sampled) # slow-json-stringify is +149.52% fasterbig-array-long-text
native x 103 ops/sec ±0.59% (76 runs sampled) slow-json-stringify x 11,480 ops/sec ±0.62% (93 runs sampled) # slow-json-stringify is +11044.66% fasterbig-array-long-number
native x 1,301 ops/sec ±0.75% (91 runs sampled) slow-json-stringify x 4,023 ops/sec ±1.07% (91 runs sampled) # slow-json-stringify is +209.46% fasterundefined properties
native x 2,456,945 ops/sec ±0.60% (95 runs sampled) fast-json-stringify x 8,646,794 ops/sec ±0.49% (93 runs sampled) slow-json-stringify x 23,159,091 ops/sec ±0.57% (89 runs sampled) # slow-json-stringify is +167.83% fasterAfter
Benchmarks
Benchmarks performed on:
small-object
native x 4,418,329 ops/sec ±0.36% (91 runs sampled) fast-json-stringify x 62,240,693 ops/sec ±0.41% (93 runs sampled) slow-json-stringify x 70,296,883 ops/sec ±0.49% (94 runs sampled) # slow-json-stringify is +12.94% fastersmall-array
native x 382,636 ops/sec ±0.39% (91 runs sampled) fast-json-stringify x 355,617 ops/sec ±0.34% (95 runs sampled) slow-json-stringify x 1,504,099 ops/sec ±0.42% (93 runs sampled) # slow-json-stringify is +293.09% fasternested-props-short-text
native x 958,195 ops/sec ±0.48% (92 runs sampled) fast-json-stringify x 4,036,352 ops/sec ±0.48% (93 runs sampled) slow-json-stringify x 16,360,174 ops/sec ±0.78% (86 runs sampled) # slow-json-stringify is +305.32% fastermuch-props-short-text
native x 860,514 ops/sec ±0.42% (92 runs sampled) fast-json-stringify x 1,067,713 ops/sec ±0.47% (97 runs sampled) slow-json-stringify x 3,505,841 ops/sec ±0.67% (92 runs sampled) # slow-json-stringify is +228.35% fastermuch-props-big-text
native x 22,928 ops/sec ±0.69% (94 runs sampled) fast-json-stringify x 21,234 ops/sec ±0.81% (92 runs sampled) slow-json-stringify x 3,854,902 ops/sec ±0.38% (93 runs sampled) # slow-json-stringify is +16713.08% fasterbig-text
native x 284,610 ops/sec ±0.41% (92 runs sampled) fast-json-stringify x 299,126 ops/sec ±0.38% (95 runs sampled) slow-json-stringify x 74,967,337 ops/sec ±1.44% (89 runs sampled) # slow-json-stringify is +24962.13% fasterbig-array-short-text
native x 4,885 ops/sec ±0.57% (91 runs sampled) slow-json-stringify x 12,722 ops/sec ±0.63% (91 runs sampled) # slow-json-stringify is +160.46% fasterbig-array-long-text
native x 108 ops/sec ±0.55% (79 runs sampled) slow-json-stringify x 12,935 ops/sec ±0.26% (91 runs sampled) # slow-json-stringify is +11876.85% fasterbig-array-long-number
native x 1,377 ops/sec ±0.35% (94 runs sampled) slow-json-stringify x 4,512 ops/sec ±0.91% (89 runs sampled) # slow-json-stringify is +227.91% fasterundefined properties
native x 2,656,347 ops/sec ±0.50% (92 runs sampled) fast-json-stringify x 8,344,745 ops/sec ±0.30% (96 runs sampled) slow-json-stringify x 26,317,667 ops/sec ±0.46% (92 runs sampled) # slow-json-stringify is +215.38% fasterRun on a 2019 MB Pro i7 2,6 Ghz.
This is achieved by:
?.syntax instead of||{}infind(but I also optimized the old_find- you can take a look)(cc developit/microbundle#892 for more mangling 'performance', since the hoisting lead to less byte savings in the bundle)