René's URL Explorer Experiment


Title: node-api: use fast properties in node_api_create_object_with_properties by colinhacks · Pull Request #66470 · nodejs/node · GitHub

Open Graph Title: node-api: use fast properties in node_api_create_object_with_properties by colinhacks · Pull Request #66470 · nodejs/node

X Title: node-api: use fast properties in node_api_create_object_with_properties by colinhacks · Pull Request #66470 · nodejs/node

Description: Description Objects created with node_api_create_object_with_properties() are in dictionary mode, because the call uses v8::Object::New(). Their properties are about 7x slower to read than an object literal's, and about 70x slower with a NULL prototype, where each object also gets a map of its own. This change keeps a cache of v8::DictionaryTemplate per env, keyed by a hash of the property names. Core already creates objects from dictionary templates in cares_wrap.cc and other places. A list of names passed once is only recorded by its hash. When the same list comes back, a template is created for it. Later objects with those names are instances of the template, with fast properties and one shared map. The first 256 lists that come back keep their template for the life of the env. Later lists keep using v8::Object::New(). Symbols, strings that are not one-byte, array-index names, duplicate names and lists of more than 127 names also keep using v8::Object::New(), because a template cannot hold them. A prototype other than Object.prototype costs one SetPrototype() per object, as in NewDictionaryInstanceNullProto(). Fixes #66441 Benchmark Measured with benchmark/compare.js, 30 runs per binary, both built from adcd028 on an Apple M1 Max (macOS 26.6) that was also running other work. The benchmark uses 20 properties and a NULL prototype. Every row below has p < 0.001 (Welch's t-test). operation n before (ops/s) after (ops/s) after / before create 100 906,183 788,484 0.87 create 1,000 826,700 1,128,979 1.37 create 10,000 1,234,144 950,498 0.77 create 100,000 1,338,166 699,711 0.52 create 1,000,000 529,317 400,732 0.76 read 100 1,427,576 2,501,004 1.75 read 1,000 3,420,600 11,972,203 3.50 read 10,000 5,376,966 19,301,626 3.59 read 100,000 6,765,430 57,977,854 8.57 read 1,000,000 6,834,671 73,790,321 10.80 The rows with method='old' (napi_create_object and napi_set_property) do not use the changed code. They moved by -1% to +7%. Creation with a NULL prototype is slower because of the SetPrototype() call. With Object.prototype it is unchanged. The reproduction from #66441 measures both, with 10 properties and 100,000 objects, in ns per property (median of 3 runs; an object literal reads at 0.78 ns): prototype read before read after create before create after Object.prototype 5.67 0.72 38.4 39.3 NULL 53.08 0.84 41.6 62.2 Validation python3 tools/test.py --mode=release js-native-api node-api benchmark/test-benchmark-napi out/Release/cctest --gtest_filter='*NodeApi*:*Napi*' make lint-cpp, git-clang-format, and ESLint on the changed JS files The new test fails on the unpatched build at the first fast-properties check. It passed 300 runs in a row on the patched build. AI disclosure: I used a coding agent for the investigation, patch, benchmarks, and PR text. It checked the template and Object::New() behavior against the V8 source, built Node.js, and ran the tests above. I approved the PR and will handle review comments myself.

Open Graph Description: Description Objects created with node_api_create_object_with_properties() are in dictionary mode, because the call uses v8::Object::New(). Their properties are about 7x slower to read than an objec...

X Description: Description Objects created with node_api_create_object_with_properties() are in dictionary mode, because the call uses v8::Object::New(). Their properties are about 7x slower to read than an objec...

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

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/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:e5b13761-d3a9-f69a-2f44-a1e244fd41f1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB784:1B3224:83DA21:B55A62:6AEDCD48
html-safe-nonce547f805851bd1dde1b9aecc46d13aa61beae2e9c12225f7ee8471a451603300b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzg0OjFCMzIyNDo4M0RBMjE6QjU1QTYyOjZBRURDRDQ4IiwidmlzaXRvcl9pZCI6IjUxODUyNjA4NjM3Mzk1MTQxODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2159ece99d3b110c8d3ffaee3200b096791cbac34e79aaaceca15e9545fec6ac
hovercard-subject-tagpull_request:4722036984
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/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
twitter:imagehttps://avatars.githubusercontent.com/u/3084745?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3084745?s=400&v=4
og:image:altDescription Objects created with node_api_create_object_with_properties() are in dictionary mode, because the call uses v8::Object::New(). Their properties are about 7x slower to read than an objec...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef60373873bb1ef795e8511ea1f2a76997e9c649d72b02942aedf2def3423a0ce
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-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0f55cfa61438c7dc93d1024a1e5e5182b36830e2
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F66470%2Fcommits%2F0087afc0a739cdb7469ed2647381a0782262f22e
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%2F66470%2Fcommits%2F0087afc0a739cdb7469ed2647381a0782262f22e
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%2Fcommits&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Reloadhttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Reloadhttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues655 (655)https://github.com/nodejs/node/issues
Pull requests664 (664)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
colinhackshttps://github.com/colinhacks
nodejs:mainhttps://github.com/nodejs/node/tree/main
colinhacks:node-api-object-shape-cachehttps://github.com/colinhacks/node/tree/node-api-object-shape-cache
Conversation 8 https://github.com/nodejs/node/pull/66470
Commits 1 https://github.com/nodejs/node/pull/66470/commits
Checks 45 https://github.com/nodejs/node/pull/66470/checks
Files changed 6 https://github.com/nodejs/node/pull/66470/files
node-api: use fast properties in node_api_create_object_with_properties https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#top
Show all changes 1 commit https://github.com/nodejs/node/pull/66470/files
0087afc node-api: use fast properties in node_api_create_object_with_properties colinhacks Oct 2, 2026 https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Clear filters https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Please reload this pagehttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Please reload this pagehttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
binding.cc https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-cf6d55876655893a2796477bc371d9a6791d395ef4fa8a13d56bc6fea94aab2d
index.js https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-3f4bf0e37dfdf1727140035bb59265452a05f08149ad74887b70167286bc63f2
js_native_api_v8.cc https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
js_native_api_v8.h https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
test_object.c https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
test_object_with_properties.js https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-7ac76ad424c743a8e4a494588661614939c9340f99b82fcd5f38fcf5a7d11236
#66441https://github.com/nodejs/node/issues/66441
Please reload this pagehttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
https://github.com/colinhacks
colinhackshttps://github.com/nodejs/node/commits?author=colinhacks
benchmark/napi/create_object_with_properties/binding.cchttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-cf6d55876655893a2796477bc371d9a6791d395ef4fa8a13d56bc6fea94aab2d
View file https://github.com/nodejs/node/blob/0087afc0a739cdb7469ed2647381a0782262f22e/benchmark/napi/create_object_with_properties/binding.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/66470/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-cf6d55876655893a2796477bc371d9a6791d395ef4fa8a13d56bc6fea94aab2d
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-cf6d55876655893a2796477bc371d9a6791d395ef4fa8a13d56bc6fea94aab2d
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-cf6d55876655893a2796477bc371d9a6791d395ef4fa8a13d56bc6fea94aab2d
benchmark/napi/create_object_with_properties/index.jshttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-3f4bf0e37dfdf1727140035bb59265452a05f08149ad74887b70167286bc63f2
View file https://github.com/nodejs/node/blob/0087afc0a739cdb7469ed2647381a0782262f22e/benchmark/napi/create_object_with_properties/index.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/66470/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-3f4bf0e37dfdf1727140035bb59265452a05f08149ad74887b70167286bc63f2
src/js_native_api_v8.cchttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
View file https://github.com/nodejs/node/blob/0087afc0a739cdb7469ed2647381a0782262f22e/src/js_native_api_v8.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/66470/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1
src/js_native_api_v8.hhttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
View file https://github.com/nodejs/node/blob/0087afc0a739cdb7469ed2647381a0782262f22e/src/js_native_api_v8.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/66470/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-5ce201326b61f008b7515e8db2290224fd5fe8e3e7133e3f00ee489e7809b8c5
test/js-native-api/test_object/test_object.chttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
View file https://github.com/nodejs/node/blob/0087afc0a739cdb7469ed2647381a0782262f22e/test/js-native-api/test_object/test_object.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/66470/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
https://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e#diff-1a6808fd8fc22b93d265cab3a30ebef378786765e9d76fa2b05c9a3188615fa6
Please reload this pagehttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
Please reload this pagehttps://github.com/nodejs/node/pull/66470/commits/0087afc0a739cdb7469ed2647381a0782262f22e
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.