Skip to content

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

Closed
mertcanaltin wants to merge 1 commit into
nodejs:mainfrom
mertcanaltin:mert/readfileutf8-zero-copy-fast-path
Closed

mertcanaltin wants to merge 1 commit 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%

@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 file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels May 16, 2026
@codecov

codecov Bot commented May 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.06%. Comparing base (