René's URL Explorer Experiment


Title: buffer: let Buffer.of use heap by ChALkeR · Pull Request #60503 · nodejs/node · GitHub

Open Graph Title: buffer: let Buffer.of use heap by ChALkeR · Pull Request #60503 · nodejs/node

X Title: buffer: let Buffer.of use heap by ChALkeR · Pull Request #60503 · nodejs/node

Description: See also #60372. This is a somewhat less performant version than that PR, but significantly faster than main and is non semver-major (so it can be backported) and does not need doc changes. Buffer.of is usually used on small static sizes (checked with GitHub codesearch) The assumption that createUnsafeBuffer(size) is faster than new Uint8Array(size) / new FastBuffer(size) is incorrect for small sizes, as the latter does not call our allocator at all when it can go to heap, and the former is always an alloc. Not letting it go to heap is hurting performance, direct allocations are slow. See #26301 for context But even past the v8_typed_array_max_size_in_heap size (which is 64 bytes in the default config), this is still not worse than the old version way past expected Buffer.of sizes Before: % out/Release/node.0 benchmark/buffers/buffer-of.js buffers/buffer-of.js n=500000 len=0: 24,633,954.827485334 buffers/buffer-of.js n=500000 len=1: 26,160,564.38801611 buffers/buffer-of.js n=500000 len=2: 26,280,949.92493504 buffers/buffer-of.js n=500000 len=8: 22,938,007.012818534 buffers/buffer-of.js n=500000 len=64: 9,478,358.537868412 buffers/buffer-of.js n=500000 len=256: 2,702,711.2345046536 buffers/buffer-of.js n=500000 len=1024: 974,881.6079890658 buffers/buffer-of.js n=500000 len=2048: 528,368.570893787 After: % out/Release/node.2 benchmark/buffers/buffer-of.js buffers/buffer-of.js n=500000 len=0: 33,703,264.18068379 buffers/buffer-of.js n=500000 len=1: 35,216,496.263314925 buffers/buffer-of.js n=500000 len=2: 34,097,195.761377595 buffers/buffer-of.js n=500000 len=8: 27,875,878.880465902 buffers/buffer-of.js n=500000 len=64: 10,335,418.86238334 buffers/buffer-of.js n=500000 len=256: 2,763,676.639751257 buffers/buffer-of.js n=500000 len=1024: 981,007.050158241 buffers/buffer-of.js n=500000 len=2048: 523,017.20255880937 For comparison, #60372 (even faster, but does that via pooling): % ./out/Release/node.pooled benchmark/buffers/buffer-of.js buffers/buffer-of.js n=500000 len=0: 33,882,981.248046815 buffers/buffer-of.js n=500000 len=1: 44,826,164.135482594 buffers/buffer-of.js n=500000 len=2: 44,895,948.02845056 buffers/buffer-of.js n=500000 len=8: 31,774,014.66683433 buffers/buffer-of.js n=500000 len=64: 10,511,875.791675644 buffers/buffer-of.js n=500000 len=256: 3,666,954.9211037415 buffers/buffer-of.js n=500000 len=1024: 1,082,339.2273017906 buffers/buffer-of.js n=500000 len=2048: 554,083.8215035282 Realistically, sizes 0-8 are most important. Benchmark code (taken from #60372 with some adjustments): 'use strict'; const common = require('../common.js'); // Measure Buffer.of(...items) throughput for various lengths. // We prebuild the items array to avoid measuring array construction, // and vary the effective iterations with length to keep total work reasonable. const bench = common.createBenchmark(main, { len: [0, 1, 2, 8, 64, 256, 1024, 2048], n: [5e5], }); function main({ len, n }) { if (len < 10) n *= 10; // noisy otherwise // Inline small numbers calls as this is fast enough for small changes to be significant switch (len) { case 0: bench.start(); for (let i = 0; i < n; i++) Buffer.of(); bench.end(n); break; case 1: bench.start(); for (let i = 0; i < n; i++) Buffer.of(0); bench.end(n); break; case 2: bench.start(); for (let i = 0; i < n; i++) Buffer.of(0, 1); bench.end(n); break; case 8: bench.start(); for (let i = 0; i < n; i++) Buffer.of(0, 1, 2, 3, 4, 5, 6, 7); bench.end(n); break; default: { const items = new Array(len); for (let i = 0; i < len; i++) items[i] = i & 0xFF; bench.start(); for (let i = 0; i < n; i++) { Buffer.of(...items); } bench.end(n); } } }

Open Graph Description: See also #60372. This is a somewhat less performant version than that PR, but significantly faster than main and is non semver-major (so it can be backported) and does not need doc changes. Buffer....

X Description: See also #60372. This is a somewhat less performant version than that PR, but significantly faster than main and is non semver-major (so it can be backported) and does not need doc changes. Buffer....

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

X: @github

direct link

Domain: redirect.github.com

route-pattern/:user_id/:repository/pull/:id/files/:range(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6a62b23f-e428-681c-6442-0d308337f335
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9C6E:229D5F:37431C2:49731AC:6A655C30
html-safe-nonce44f7aa98cf8a6fb7c2409215fdd1f6a5e3249db4f94d35047e109fdc15885e88
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzZFOjIyOUQ1RjozNzQzMUMyOjQ5NzMxQUM6NkE2NTVDMzAiLCJ2aXNpdG9yX2lkIjoiMTE5NjUyNzA5NzA1Mjc2NDY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1fc4cd43b47bdd6838d9bb00eb8469a693a9abd6a1762f8f51931cbe647e2536
hovercard-subject-tagpull_request:2965045375
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/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
twitter:imagehttps://avatars.githubusercontent.com/u/291301?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/291301?s=400&v=4
og:image:altSee also #60372. This is a somewhat less performant version than that PR, but significantly faster than main and is non semver-major (so it can be backported) and does not need doc changes. Buffer....
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
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
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae#start-of-content
https://redirect.github.com/
Sign in https://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F60503%2Ffiles%2F1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F60503%2Ffiles%2F1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Sign up https://redirect.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://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Reloadhttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Reloadhttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
nodejs https://redirect.github.com/nodejs
nodehttps://redirect.github.com/nodejs/node
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Notifications https://redirect.github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36.1k https://redirect.github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://redirect.github.com/login?return_to=%2Fnodejs%2Fnode
Code https://redirect.github.com/nodejs/node
Issues 1.3k https://redirect.github.com/nodejs/node/issues
Pull requests 1.1k https://redirect.github.com/nodejs/node/pulls
Actions https://redirect.github.com/nodejs/node/actions
Projects https://redirect.github.com/nodejs/node/projects
Security and quality 0 https://redirect.github.com/nodejs/node/security
Insights https://redirect.github.com/nodejs/node/pulse
Code https://redirect.github.com/nodejs/node
Issues https://redirect.github.com/nodejs/node/issues
Pull requests https://redirect.github.com/nodejs/node/pulls
Actions https://redirect.github.com/nodejs/node/actions
Projects https://redirect.github.com/nodejs/node/projects
Security and quality https://redirect.github.com/nodejs/node/security
Insights https://redirect.github.com/nodejs/node/pulse
Sign up for GitHub https://redirect.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://redirect.github.com/login?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
nodejs-github-bothttps://redirect.github.com/nodejs-github-bot
nodejs:mainhttps://redirect.github.com/nodejs/node/tree/main
ChALkeR:chalker/brrr/1https://redirect.github.com/ChALkeR/io.js/tree/chalker/brrr/1
Conversation 9 https://redirect.github.com/nodejs/node/pull/60503
Commits 1 https://redirect.github.com/nodejs/node/pull/60503/commits
Checks 42 https://redirect.github.com/nodejs/node/pull/60503/checks
Files changed https://redirect.github.com/nodejs/node/pull/60503/files
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
buffer: let Buffer.of use heap https://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae#top
Show all changes 1 commit https://redirect.github.com/nodejs/node/pull/60503/files
1a8aac1 buffer: let Buffer.of use heap ChALkeR Oct 31, 2025 https://redirect.github.com/nodejs/node/pull/60503/commits/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Clear filters https://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
lib/buffer.jshttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae#diff-3c2cd5c512dd026a7765b6b2ae3f85785d3b7ea3795e11949892b7b73beee630
View file https://redirect.github.com/ChALkeR/io.js/blob/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae/lib/buffer.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/nodejs/node/pull/60503/files/{{ revealButtonHref }}
https://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae#diff-3c2cd5c512dd026a7765b6b2ae3f85785d3b7ea3795e11949892b7b73beee630
https://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae#diff-3c2cd5c512dd026a7765b6b2ae3f85785d3b7ea3795e11949892b7b73beee630
Please reload this pagehttps://redirect.github.com/nodejs/node/pull/60503/files/1a8aac15fc296b67e38b6d9ef9f5a1239aa3b8ae
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.