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

perf: various performance improvements #17135

Merged
merged 12 commits into from Jun 22, 2023
Merged

Conversation

moonlightaria
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ X] Other, please explain:

What changes did you make? (Give an overview)

made various performance improvements to various parts of the code mainly based around removing unnecessary object creation and overhead from the functional tools (map, filter, reduce)

Is there anything you'd like reviewers to focus on?

@moonlightaria moonlightaria requested a review from a team as a code owner April 29, 2023 08:09
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 29, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@eslint-github-bot eslint-github-bot bot added the chore This change is not user-facing label Apr 29, 2023
@netlify
Copy link

netlify bot commented Apr 29, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 3ea3d29
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/644cd0ca56143d00085191c4

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

For perf-related improvements, we should include before & after data that shows the improvement. Can you provide some tests and results? For rules, you could use TIMING.

@mdjermanovic
Copy link
Member

overhead from the functional tools (map, filter, reduce)

These methods are commonly used, and therefore highly optimized in JS engines. I wouldn't expect for-loops to be noticeably faster (in fact, it might be the opposite), and that might depend on the engine and its version, so unless there's a significant difference in performance, I'm not in favor of making these changes.

@moonlightaria
Copy link
Contributor Author

moonlightaria commented Apr 30, 2023

benchs.zip
here are the benchmarks on before and after the changes i just ran

for foreach it is often faster for very small collections since there is less code for js to compile but filter and map always creates a new array which becomes a performance burden expecially when chained since each on creates it own array

for some the improvement are hard to spot since it is removing garbage collection which can appear in random locations outside of the function

@nzakas
Copy link
Member

nzakas commented May 9, 2023

@moonlightaria can you please paste a summary in this PR? Generally we try not to download zip files of unknown origins. :)

@moonlightaria
Copy link
Contributor Author

benchmark command: node --cpu-prof ../../bin/eslint.js large.js --no-ignore
decided to run new benchmarks and several for better info, lost benchmark command used during initial runs so used new ones

some improvements are minimal while other are major, optimizations which reduce memory allocation remove gc cycles which can occur outside of the functions which isn't captured in this quick summery

if functions didn't appear it means no trace was grabbed during the execution of that function generally meaning that execution time to too small matter

addparensindent:
old:
438.54 ms
411.72 ms
459.63 ms
avg: 436.63 ms

new:
433.95 ms
437.45 ms
429.41 ms
avg: 433.60 ms

removeLeadingZeros:
old:
30.34 ms
20.03 ms
27.29 ms

new:
didn't appear
didn't appear
1.26 ms

removeTrailingZeros:
old:
8.04 ms
22.84 ms
11.05 ms

new:
didn't appear
didn't appear
2.61 ms

checklist:
old:
3.93 ms
.76 ms
1.24 ms
avg: 1.97 ms

new:
.42 ms
.69 ms
2.13 ms
avg: 1.08 ms

calculateStatsPerFile:
old:
26.82 ms
8.87 ms
23.44 ms
avg: 19.71 ms

new:
4.82 ms
4.88 ms
9.84 ms
avg: 6.51 ms

calculateStatsPerRun:
no appearance on any profile, same optimization as calculateStatsPerFile

checkProgramForMaxLength:
old:
168.78 ms
148.38 ms
178.24 ms
avg: 165.13 ms

new:
157.43 ms
153.75 ms
151.78 ms
avg: 154.32 ms

TokenInfo constructor:
old:
34.92 ms
39.39 ms
38.49 ms
avg: 37.6

new:
24.88 ms
34.23 ms
25.47 ms
avg: 28.19

check:
no appearance on any profile, replaced filter array creation and length check with incrementing an integer

create:
old:
37.75 ms
41.10 ms
33.16 ms
avg: 37.33 ms

new:
37.12 ms
39.41 ms
41.81 ms
avg: 39.44 ms

@github-actions
Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label May 20, 2023
@Rec0iL99
Copy link
Member

benchmark command: node --cpu-prof ../../bin/eslint.js large.js --no-ignore decided to run new benchmarks and several for better info, lost benchmark command used during initial runs so used new ones

some improvements are minimal while other are major, optimizations which reduce memory allocation remove gc cycles which can occur outside of the functions which isn't captured in this quick summery

if functions didn't appear it means no trace was grabbed during the execution of that function generally meaning that execution time to too small matter

addparensindent: old: 438.54 ms 411.72 ms 459.63 ms avg: 436.63 ms

new: 433.95 ms 437.45 ms 429.41 ms avg: 433.60 ms

removeLeadingZeros: old: 30.34 ms 20.03 ms 27.29 ms

new: didn't appear didn't appear 1.26 ms

removeTrailingZeros: old: 8.04 ms 22.84 ms 11.05 ms

new: didn't appear didn't appear 2.61 ms

checklist: old: 3.93 ms .76 ms 1.24 ms avg: 1.97 ms

new: .42 ms .69 ms 2.13 ms avg: 1.08 ms

calculateStatsPerFile: old: 26.82 ms 8.87 ms 23.44 ms avg: 19.71 ms

new: 4.82 ms 4.88 ms 9.84 ms avg: 6.51 ms

calculateStatsPerRun: no appearance on any profile, same optimization as calculateStatsPerFile

checkProgramForMaxLength: old: 168.78 ms 148.38 ms 178.24 ms avg: 165.13 ms

new: 157.43 ms 153.75 ms 151.78 ms avg: 154.32 ms

TokenInfo constructor: old: 34.92 ms 39.39 ms 38.49 ms avg: 37.6

new: 24.88 ms 34.23 ms 25.47 ms avg: 28.19

check: no appearance on any profile, replaced filter array creation and length check with incrementing an integer

create: old: 37.75 ms 41.10 ms 33.16 ms avg: 37.33 ms

new: 37.12 ms 39.41 ms 41.81 ms avg: 39.44 ms

@moonlightaria has provided some form of summary that was requested.

cc @mdjermanovic

@Rec0iL99 Rec0iL99 removed the Stale label May 21, 2023
@github-actions
Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label May 31, 2023
@Rec0iL99 Rec0iL99 removed the Stale label May 31, 2023
@Rec0iL99
Copy link
Member

benchmark command: node --cpu-prof ../../bin/eslint.js large.js --no-ignore decided to run new benchmarks and several for better info, lost benchmark command used during initial runs so used new ones
some improvements are minimal while other are major, optimizations which reduce memory allocation remove gc cycles which can occur outside of the functions which isn't captured in this quick summery
if functions didn't appear it means no trace was grabbed during the execution of that function generally meaning that execution time to too small matter
addparensindent: old: 438.54 ms 411.72 ms 459.63 ms avg: 436.63 ms
new: 433.95 ms 437.45 ms 429.41 ms avg: 433.60 ms
removeLeadingZeros: old: 30.34 ms 20.03 ms 27.29 ms
new: didn't appear didn't appear 1.26 ms
removeTrailingZeros: old: 8.04 ms 22.84 ms 11.05 ms
new: didn't appear didn't appear 2.61 ms
checklist: old: 3.93 ms .76 ms 1.24 ms avg: 1.97 ms
new: .42 ms .69 ms 2.13 ms avg: 1.08 ms
calculateStatsPerFile: old: 26.82 ms 8.87 ms 23.44 ms avg: 19.71 ms
new: 4.82 ms 4.88 ms 9.84 ms avg: 6.51 ms
calculateStatsPerRun: no appearance on any profile, same optimization as calculateStatsPerFile
checkProgramForMaxLength: old: 168.78 ms 148.38 ms 178.24 ms avg: 165.13 ms
new: 157.43 ms 153.75 ms 151.78 ms avg: 154.32 ms
TokenInfo constructor: old: 34.92 ms 39.39 ms 38.49 ms avg: 37.6
new: 24.88 ms 34.23 ms 25.47 ms avg: 28.19
check: no appearance on any profile, replaced filter array creation and length check with incrementing an integer
create: old: 37.75 ms 41.10 ms 33.16 ms avg: 37.33 ms
new: 37.12 ms 39.41 ms 41.81 ms avg: 39.44 ms

@moonlightaria has provided some form of summary that was requested.

cc @mdjermanovic

cc @nzakas @mdjermanovic

@github-actions
Copy link

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Jun 11, 2023
@Rec0iL99
Copy link
Member

Friendly ping @nzakas @mdjermanovic, this pr is open for quite a while now. I think author has provided the requested info. How do we proceed?

@Rec0iL99 Rec0iL99 removed the Stale label Jun 14, 2023
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks, sorry for losing track of this. I feel comfortable with the changes, though the perf improvement seems a bit small and we are arguably losing some readability along the way.

I'm okay with merging if @mdjermanovic approves; also okay with not merging.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jun 22, 2023
@mdjermanovic mdjermanovic merged commit f82e56e into eslint:main Jun 22, 2023
22 checks passed
@nzakas
Copy link
Member

nzakas commented Jun 29, 2023

@moonlightaria we'd like to pay you for this contribution. Please contact us at contact (at) eslint (dot) org.

json-derulo added a commit to json-derulo/angular-ecmascript-intl that referenced this pull request Jul 4, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint](https://eslint.org)
([source](https://togithub.com/eslint/eslint)) | devDependencies | minor
| [`8.43.0` ->
`8.44.0`](https://renovatebot.com/diffs/npm/eslint/8.43.0/8.44.0) |

---

### Release Notes

<details>
<summary>eslint/eslint (eslint)</summary>

### [`v8.44.0`](https://togithub.com/eslint/eslint/releases/tag/v8.44.0)

[Compare
Source](https://togithub.com/eslint/eslint/compare/v8.43.0...v8.44.0)

#### Features

-
[`1766771`](https://togithub.com/eslint/eslint/commit/176677180a4a1209fc192771521c9192e1f67578)
feat: add `es2023` and `es2024` environments
(#&#8203;1[eslint/eslint#17328))
(Milos Djermanovic)
-
[`4c50400`](https://togithub.com/eslint/eslint/commit/4c5040022639ae804c15b366afc6e64982bd8ae3)
feat: add `ecmaVersion: 2024`, regexp `v` flag parsing
(#&#8203;1[eslint/eslint#17324))
(Milos Djermanovic)
-
[`4d411e4`](https://togithub.com/eslint/eslint/commit/4d411e4c7063274d6d346f1b7ee46f7575d0bbd2)
feat: add ternaryOperandBinaryExpressions option to no-extra-parens rule
(#&#8203;1[eslint/eslint#17270))
(Percy Ma)
-
[`c8b1f4d`](https://togithub.com/eslint/eslint/commit/c8b1f4d61a256727755d561bf53f889b6cd712e0)
feat: Move `parserServices` to `SourceCode`
(#&#8203;1[eslint/eslint#17311))
(Milos Djermanovic)
-
[`ef6e24e`](https://togithub.com/eslint/eslint/commit/ef6e24e42670f321d996948623846d9caaedac99)
feat: treat unknown nodes as having the lowest precedence
(#&#8203;1[eslint/eslint#17302))
(Brad Zacher)
-
[`1866e1d`](https://togithub.com/eslint/eslint/commit/1866e1df6175e4ba0ae4a0d88dc3c956bb310035)
feat: allow flat config files to export a Promise
(#&#8203;1[eslint/eslint#17301))
(Milos Djermanovic)

#### Bug Fixes

-
[`a36bcb6`](https://togithub.com/eslint/eslint/commit/a36bcb67f26be42c794797d0cc9948b9cfd4ff71)
fix: no-unused-vars false positive with logical assignment operators
(#&#8203;1[eslint/eslint#17320))
(Gweesin Chan)
-
[`7620b89`](https://togithub.com/eslint/eslint/commit/7620b891e81c234f30f9dbcceb64a05fd0dde65e)
fix: Remove `no-unused-labels` autofix before potential directives
(#&#8203;1[eslint/eslint#17314))
(Francesco Trotta)
-
[`391ed38`](https://togithub.com/eslint/eslint/commit/391ed38b09bd1a3abe85db65b8fcda980ab3d6f4)
fix: Remove `no-extra-semi` autofix before potential directives
(#&#8203;1[eslint/eslint#17297))
(Francesco Trotta)

#### Documentation

-
[`526e911`](https://togithub.com/eslint/eslint/commit/526e91106e6fe101578e9478a9d7f4844d4f72ac)
docs: resubmit pr 17115 doc changes
(#&#8203;1[eslint/eslint#17291))
(唯然)
-
[`e1314bf`](https://togithub.com/eslint/eslint/commit/e1314bf85a52bb0d05b1c9ca3b4c1732bae22172)
docs: Integration section and tutorial
(#&#8203;1[eslint/eslint#17132))
(Ben Perlmutter)
-
[`19a8c5d`](https://togithub.com/eslint/eslint/commit/19a8c5d84596a9f7f2aa428c1696ba86daf854e6)
docs: Update README (GitHub Actions Bot)

#### Chores

-
[`49e46ed`](https://togithub.com/eslint/eslint/commit/49e46edf3c8dc71d691a97fc33b63ed80ae0db0c)
chore: upgrade
[@&#8203;eslint/js](https://togithub.com/eslint/js)[@&#8203;8](https://togithub.com/8).44.0
(#&#8203;1[eslint/eslint#17329))
(Milos Djermanovic)
-
[`a1cb642`](https://togithub.com/eslint/eslint/commit/a1cb6421f9d185901cd99e5f696e912226ef6632)
chore: package.json update for
[@&#8203;eslint/js](https://togithub.com/eslint/js) release (ESLint
Jenkins)
-
[`840a264`](https://togithub.com/eslint/eslint/commit/840a26462bbf6c27c52c01b85ee2018062157951)
test: More test cases for no-case-declarations
(#&#8203;1[eslint/eslint#17315))
(Elian Cordoba)
-
[`e6e74f9`](https://togithub.com/eslint/eslint/commit/e6e74f9eef0448129dd4775628aba554a2d8c8c9)
chore: package.json update for eslint-config-eslint release (ESLint
Jenkins)
-
[`eb3d794`](https://togithub.com/eslint/eslint/commit/eb3d7946e1e9f70254008744dba2397aaa730114)
chore: upgrade semver@7.5.3
(#&#8203;1[eslint/eslint#17323))
(Ziyad El Abid)
-
[`cf88439`](https://togithub.com/eslint/eslint/commit/cf884390ad8071d88eae05df9321100f1770363d)
chore: upgrade optionator@0.9.3
(#&#8203;1[eslint/eslint#17319))
(Milos Djermanovic)
-
[`9718a97`](https://togithub.com/eslint/eslint/commit/9718a9781d69d2c40b68c631aed97700b32c0082)
refactor: remove unnecessary code in `flat-eslint.js`
(#&#8203;1[eslint/eslint#17308))
(Milos Djermanovic)
-
[`f82e56e`](https://togithub.com/eslint/eslint/commit/f82e56e9acfb9562ece76441472d5657d7d5e296)
perf: various performance improvements
(#&#8203;1[eslint/eslint#17135))
(moonlightaria)
-
[`da81e66`](https://togithub.com/eslint/eslint/commit/da81e66e22b4f3d3fe292cf70c388753304deaad)
chore: update eslint-plugin-jsdoc to 46.2.5
(#&#8203;1[eslint/eslint#17245))
(唯然)
-
[`b991640`](https://togithub.com/eslint/eslint/commit/b991640176d5dce4750f7cc71c56cd6f284c882f)
chore: switch eslint-config-eslint to the flat format
(#&#8203;1[eslint/eslint#17247))
(唯然)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTUuMCIsInVwZGF0ZWRJblZlciI6IjM1LjE1OS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Renovate Bot <bot@renovateapp.com>
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 20, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing contributor pool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants