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: use buffer.isUtf8 in NodePathFS #5516

Merged
merged 2 commits into from
Jun 22, 2023
Merged

Conversation

paul-soporan
Copy link
Member

What's the problem this PR addresses?

Node 18.14.0 added a new function: buffer.isUtf8

How did you fix it?

I've tested it and it's 75 times faster than our current implementation.

For an 80 MB buffer:

  • old check: 315.447ms
  • new check: 4.06ms

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@@ -140,8 +140,7 @@ export function getCaller() {

export function availableParallelism() {
// TODO: Use os.availableParallelism directly when dropping support for Node.js < 19.4.0
if (`availableParallelism` in os)
// @ts-expect-error - No types yet
if (typeof os.availableParallelism !== `undefined`)
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this check because otherwise os would have been never in the other branch.

@paul-soporan paul-soporan added this pull request to the merge queue Jun 22, 2023
Merged via the queue into master with commit 2259237 Jun 22, 2023
17 checks passed
@paul-soporan paul-soporan deleted the paul/perf/buffer-isutf8 branch June 22, 2023 22:27
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

Successfully merging this pull request may close these issues.

2 participants