Skip to content

fs: dispatch ASCII and Latin1 via simdutf in ReadFileUtf8#63370

Open
mertcanaltin wants to merge 2 commits into
nodejs:mainfrom
mertcanaltin:mert/readfileutf8-zero-copy-fast-path
Open

fs: dispatch ASCII and Latin1 via simdutf in ReadFileUtf8#63370
mertcanaltin wants to merge 2 commits into
nodejs:mainfrom
mertcanaltin:mert/readfileutf8-zero-copy-fast-path

Conversation

@mertcanaltin
Copy link
Copy Markdown
Member

In fs.readFileSync(path, 'utf8'), I dispatch the V8 string creation through simdutf. ASCII and Latin1-fits utf-8 use one-byte V8 strings, multibyte goes through simdutf to UTF-16, invalid utf-8 falls back to V8.

@nodejs/fs, @anonrig @addaleax, @lemire @mcollina

Bench results (gist): https://gist.github.com/mertcanaltin/a0096c3fad387d0bace821938754af44

fs/readfile-utf8-fastpath.js
    latin1     path 4MB     +803%
    latin1     path 256KB   +725%
    utf8_mixed path 4MB     +453%
    utf8_mixed path 256KB   +358%
    latin1     path 16KB    +309%
    latin1     fd   4MB     +238%

Signed-off-by: Mert Can Altin <mertgold60@gmail.com>
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels May 16, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 67.92453% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.04%. Comparing base (9de9b9f) to head (cdeaa76).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/node_file.cc 67.92% 11 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63370      +/-   ##
==========================================
- Coverage   90.07%   90.04%   -0.04%     
==========================================
  Files         714      714              
  Lines      225564   225613      +49     
  Branches    42656    42668      +12     
==========================================
- Hits       203177   203145      -32     
- Misses      14189    14254      +65     
- Partials     8198     8214      +16     
Files with missing lines Coverage Δ
src/node_file.cc 74.15% <67.92%> (-0.08%) ⬇️

... and 54 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants