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

lib: optimize priority queue #57100

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

gurgunday
Copy link
Contributor

Huge credit to @lemire, I only ported the parts that we can to improve performance without introducing breaking changes

First run:

After:

util/priority-queue.js

util/priority-queue.js n=100000: 6,372,311.7447058195

Before:

util/priority-queue.js

util/priority-queue.js n=100000: 5,610,982.713123359

Second run:

After:

util/priority-queue.js

util/priority-queue.js n=100000: 6,524,784.786498602

Before:

util/priority-queue.js

util/priority-queue.js n=100000: 4,854,606.242159507

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Feb 17, 2025
@gurgunday gurgunday changed the title Optimize priority lib: optimize percolate and remove operations Feb 17, 2025
@gurgunday gurgunday changed the title lib: optimize percolate and remove operations lib: optimize priority queue Feb 17, 2025
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.26%. Comparing base (fd45383) to head (db55a71).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #57100   +/-   ##
=======================================
  Coverage   90.26%   90.26%           
=======================================
  Files         630      630           
  Lines      184634   184645   +11     
  Branches    36137    36126   -11     
=======================================
+ Hits       166654   166675   +21     
+ Misses      11022    11017    -5     
+ Partials     6958     6953    -5     
Files with missing lines Coverage Δ
lib/internal/priority_queue.js 99.19% <100.00%> (+0.07%) ⬆️

... and 44 files with indirect coverage changes

@targos targos added the needs-benchmark-ci PR that need a benchmark CI run. label Feb 17, 2025
@gurgunday
Copy link
Contributor Author

@aduh95 would you like to take a look as well?

@gurgunday gurgunday requested a review from aduh95 February 23, 2025 12:38
@aduh95
Copy link
Contributor

aduh95 commented Feb 23, 2025

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1660/

                                confidence improvement accuracy (*)   (**)  (***)
util/priority-queue.js n=100000        ***      7.48 %       ±1.29% ±1.72% ±2.23%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 1 comparisons, you can thus
expect the following amount of false-positive results:
  0.05 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.01 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Feb 23, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 23, 2025
@nodejs-github-bot
Copy link
Collaborator

@gurgunday
Copy link
Contributor Author

@aduh95 can we try again? I rebased maybe there was a flaky test

@aduh95
Copy link
Contributor

aduh95 commented Feb 28, 2025

@gurgunday yes it was likely a flaky test. However, please don't rebase in this case, we can resume the failing jobs (when you rebase, we have re-run the whole suite). When getting a flaky test, you can search for issues reporting them (if we ignore them, they're only going to pile up until the CI is completely unusable); I've (re)opened the following issues to track those flakes:

@nodejs-github-bot
Copy link
Collaborator

@gurgunday
Copy link
Contributor Author

gurgunday commented Feb 28, 2025

@aduh95 sorry for that, I didn't know

Thanks for the response, I'll try to take a look at these flaky tests as well!

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Feb 28, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 28, 2025
@nodejs-github-bot nodejs-github-bot merged commit 52ecb96 into nodejs:main Feb 28, 2025
58 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 52ecb96

@gurgunday gurgunday deleted the optimize-priority branch February 28, 2025 16:45
aduh95 pushed a commit that referenced this pull request Mar 9, 2025
PR-URL: #57100
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants