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

buffer: make indexOf(byte) faster #53455

Merged
merged 1 commit into from
Jun 16, 2024

Conversation

tniessen
Copy link
Member

Add a V8 fast API implementation for indexOfNumber, which significantly improves the performance of finding a single byte within a buffer.

Local benchmark:

                                                    confidence improvement accuracy (*)   (**)  (***)
buffers/buffer-indexof-number.js n=1000000 value=64        ***     57.69 %       ±5.47% ±7.29% ±9.52%

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 (***)

Refs: #52993

Add a V8 fast API implementation for indexOfNumber, which significantly
improves the performance of finding a single byte within a buffer.

Refs: nodejs#52993
@tniessen tniessen added buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js. labels Jun 14, 2024
@tniessen tniessen requested a review from ronag June 14, 2024 17:16
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jun 14, 2024
@tniessen tniessen 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 Jun 14, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2024
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@tniessen tniessen added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 15, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 16, 2024
@nodejs-github-bot nodejs-github-bot merged commit 103623b into nodejs:main Jun 16, 2024
70 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 103623b

@ronag
Copy link
Member

ronag commented Jun 20, 2024

Just a quick question. Any reason why we are not using Uint8Array.prototype.indexOf provided by V8?

targos pushed a commit that referenced this pull request Jun 20, 2024
Add a V8 fast API implementation for indexOfNumber, which significantly
improves the performance of finding a single byte within a buffer.

Refs: #52993
PR-URL: #53455
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
EliphazB pushed a commit to EliphazB/node that referenced this pull request Jun 20, 2024
Add a V8 fast API implementation for indexOfNumber, which significantly
improves the performance of finding a single byte within a buffer.

Refs: nodejs#52993
PR-URL: nodejs#53455
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
Add a V8 fast API implementation for indexOfNumber, which significantly
improves the performance of finding a single byte within a buffer.

Refs: nodejs#52993
PR-URL: nodejs#53455
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
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. buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants