René's URL Explorer Experiment


Title: fs: read small files in one thread pool round trip by codebytere · Pull Request #65327 · nodejs/node · GitHub

Open Graph Title: fs: read small files in one thread pool round trip by codebytere · Pull Request #65327 · nodejs/node

X Title: fs: read small files in one thread pool round trip by codebytere · Pull Request #65327 · nodejs/node

Description: fs.readFile() / fs.promises.readFile() of small files get 3–6× faster, and use one libuv thread-pool task instead of four, by doing open + fstat + read + close in a single round trip. fs/readfile.js len=1024 concurrent=1 *** 204.95 % ±2.29% fs/readfile.js len=1024 concurrent=10 *** 299.99 % ±4.58% fs/readfile-promises.js len=1024 concurrent=1 *** 238.56 % ±2.68% fs/readfile-promises.js len=1024 concurrent=10 *** 500.14 % ±5.17% fs/readfile-promises.js len=524288 concurrent=10 encoding='utf-8' *** 132.83 % ±8.34% fs/readfile-partitioned.js len=1024 concurrent=10 (vs. zlib work) *** 240.87 % fs/readfile*.js len ≥ 4 MiB ~0 % n.s. (one exception below) fs.readFile() of 4 KiB files at concurrency 64: ~51 k → ~306 k files/s; mixed with fs.stat + dns.lookup: ~66 k → ~312 k ops/s (Linux x64, --set duration=2, 30 runs.) Today a path-based readFile issues open, fstat, read and close as four separate uv_fs_* requests, each with its own queue wait, completion callback and JS↔C++ crossing; the promise API does the same through a FileHandle. For small files those round trips are the whole cost, and each one takes a pool slot away from concurrent dns/zlib/crypto/fs work. ReadFileJob (an AsyncWrap + ThreadPoolWork, provider FSREQCALLBACK) runs open + fstat + read-to-EOF + close as one task and returns the content. If the file is larger than one chunk (kReadFileBufferLength, 512 KiB) it stops after fstat and hands back the fd and size, and the existing chunked reader continues exactly as today (interleaved, abortable between chunks). Both readFiles use it for path arguments without a user buffer; fds and FileHandles are unchanged. Preserved on purpose: identical results for every size/encoding; open errors report syscall: 'open' + path, read errors 'read'; permission errors arrive through the callback/promise; an abort that lands while the round trip is in flight still wins; the handed-back fd is tracked and closed like any other; size-0 files (procfs) are read to EOF. One open point: 16–32 MiB reads via fs.promises.readFile(…, 'utf-8') at concurrency 10 measure −2…3 % (***), reproducibly; the same sizes as Buffers, via the callback API, or at concurrency 1 are flat. They take the hand-back path with identical syscalls, and direct timing shows ≤2 %, so I haven't pinned it down. If preferred, the promise API can keep its current path and only the callback API changes. Tests: test-fs-readfile-one-roundtrip.js (new; also passes on current main): sizes across the 512 KiB threshold, encodings, flags, error shapes, abort before/during, fd/FileHandle inputs, no fd leak on hand-back, procfs/sysfs, async_hooks lifecycle. Adjusted to keep testing what they test: test/async-hooks/test-fsreqcallback-readFile.js (accepts one request instead of exactly four), test-graph.fsreq-readFile.js (reads a 512 KiB+1 file so the four-request chain keeps its shape), test-async-exec-resource-match.js (resource + ≥1 fs request), test-trace-events-fs-async.js (uses fs.fstat() for the fstat trace instead of readFile as a proxy), test-fs-promises-readfile.js (zero-size-liar case goes through a FileHandle), test-fs-promises-file-handle-{op,aggregate,close}-errors.js (use a >512 KiB file so the patched FileHandle path is taken). fs, async-hooks, permission, worker, process and child_process suites pass. Disclosure: the code, test, measurements and this description were written by Claude Code, directed and reviewed by @codebytere.

Open Graph Description: fs.readFile() / fs.promises.readFile() of small files get 3–6× faster, and use one libuv thread-pool task instead of four, by doing open + fstat + read + close in a single round trip. fs/readfile.j...

X Description: fs.readFile() / fs.promises.readFile() of small files get 3–6× faster, and use one libuv thread-pool task instead of four, by doing open + fstat + read + close in a single round trip. fs/readfile.j...

Opengraph URL: https://github.com/nodejs/node/pull/65327

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c32d358b-d45b-9b74-0d6d-9b681812b254
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA9D4:1F05C8:8644C1:AEBA44:6AED3724
html-safe-nonced384912d554d5444f210dfcaa2d317a5a25f579a97ec695562ad99053ec88375
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUQ0OjFGMDVDODo4NjQ0QzE6QUVCQTQ0OjZBRUQzNzI0IiwidmlzaXRvcl9pZCI6IjYzMjU4NjgzNzA2OTExNzYyMjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0630d4a6465c92d566fe21ea304d5243519d3cf067075c6df2ceb85dc400d534
hovercard-subject-tagpull_request:4290649171
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/pull/65327/files
twitter:imagehttps://avatars.githubusercontent.com/u/2036040?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/2036040?s=400&v=4
og:image:altfs.readFile() / fs.promises.readFile() of small files get 3–6× faster, and use one libuv thread-pool task instead of four, by doing open + fstat + read + close in a single round trip. fs/readfile.j...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec629ad99c254d306375fc8354d04321c2c362236
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/65327/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F65327%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F65327%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/pull/65327/files
Reloadhttps://github.com/nodejs/node/pull/65327/files
Reloadhttps://github.com/nodejs/node/pull/65327/files
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
nodejs-github-bothttps://github.com/nodejs-github-bot
nodejs:mainhttps://github.com/nodejs/node/tree/main
codebytere:perf/fs-readfile-one-roundtriphttps://github.com/codebytere/node/tree/perf/fs-readfile-one-roundtrip
Conversation 11 https://github.com/nodejs/node/pull/65327
Commits 1 https://github.com/nodejs/node/pull/65327/commits
Checks 38 https://github.com/nodejs/node/pull/65327/checks
Files changed https://github.com/nodejs/node/pull/65327/files
Please reload this pagehttps://github.com/nodejs/node/pull/65327/files
fs: read small files in one thread pool round trip https://github.com/nodejs/node/pull/65327/files#top
Show all changes 1 commit https://github.com/nodejs/node/pull/65327/files
b626e93 fs: read small files in one thread pool round trip codebytere Aug 16, 2026 https://github.com/nodejs/node/pull/65327/commits/b626e93d3e73b484bf4c2047d604f7101ce74236
Clear filters https://github.com/nodejs/node/pull/65327/files
Please reload this pagehttps://github.com/nodejs/node/pull/65327/files
Please reload this pagehttps://github.com/nodejs/node/pull/65327/files
fs.js https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
promises.js https://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
node_file.cc https://github.com/nodejs/node/pull/65327/files#diff-70e3325bd2115867617ae2a16321c5de53c070ff2841976fe5b849675a5111e6
test-async-exec-resource-match.js https://github.com/nodejs/node/pull/65327/files#diff-40e5861ea27e5dbcca9ebd55b3d646cb9a9ca52006257456e528275e8b8cbf61
test-fsreqcallback-readFile.js https://github.com/nodejs/node/pull/65327/files#diff-14ef00d3b3b1d42b4643ff85950f498f8855365731b2ac19b8f2e58ffa5bc25b
test-graph.fsreq-readFile.js https://github.com/nodejs/node/pull/65327/files#diff-4ed2662135fdde982ed23d4aee409756d2957147e448db9af18fb3d7cf54fb80
test-fs-promises-file-handle-aggregate-errors.js https://github.com/nodejs/node/pull/65327/files#diff-4a77608ffcd0799ecede7557ffba096bc20024a508e711131054600770ad8877
test-fs-promises-file-handle-close-errors.js https://github.com/nodejs/node/pull/65327/files#diff-68ec89109e3d9e2650406c526f2d2dd57f6e08ca7f143d3577a46de4e0f13887
test-fs-promises-file-handle-op-errors.js https://github.com/nodejs/node/pull/65327/files#diff-334183fdfed936f8249b73b18bd7e745846a6a7fbcf49d8626f5d98f5e35ce19
test-fs-promises-readfile.js https://github.com/nodejs/node/pull/65327/files#diff-4217d374dc8cdf7c9a62450022fa05e96b7f426f49bbd320b9fdf4ea1367610d
test-fs-readfile-one-roundtrip.js https://github.com/nodejs/node/pull/65327/files#diff-c39489f7163ea1aa66ac133470c0d4ab3e70210f3657c7efd0f359c1163823a3
test-trace-events-fs-async.js https://github.com/nodejs/node/pull/65327/files#diff-58bfd56a19d1c3f7bd1f65f28e7624d377ea5a6b3c71ad7e7b17907901f8d729
lib/fs.jshttps://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
View file https://github.com/codebytere/node/blob/b626e93d3e73b484bf4c2047d604f7101ce74236/lib/fs.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/65327/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
https://github.com/nodejs/node/pull/65327/files#diff-9b2c5bf36570be7a09ba2597abdf6d9bc2cc1e19866b6674b0cf275c1188dcad
lib/internal/fs/promises.jshttps://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
View file https://github.com/codebytere/node/blob/b626e93d3e73b484bf4c2047d604f7101ce74236/lib/internal/fs/promises.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/65327/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
https://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
https://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
https://github.com/nodejs/node/pull/65327/files#diff-408a6d8eb0a23c586754d4f3af46c8b1927a32d80a6bdfd3bbd87c0f2a012b1a
Please reload this pagehttps://github.com/nodejs/node/pull/65327/files
Please reload this pagehttps://github.com/nodejs/node/pull/65327/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.