René's URL Explorer Experiment


Title: ffi: AllocateCodeNear() probes up to 2048 pages with a failing mmap each, costing ~790 µs per trampoline · Issue #64968 · nodejs/node · GitHub

Open Graph Title: ffi: AllocateCodeNear() probes up to 2048 pages with a failing mmap each, costing ~790 µs per trampoline · Issue #64968 · nodejs/node

X Title: ffi: AllocateCodeNear() probes up to 2048 pages with a failing mmap each, costing ~790 µs per trampoline · Issue #64968 · nodejs/node

Description: Version main Platform Linux Subsystem ffi What steps will reproduce the bug? repro.c #include // Fast-eligible: 2 register arguments, scalar return. Resolving this signature // makes CreateFastFFIMetadata() emit a trampoline t...

Open Graph Description: Version main Platform Linux Subsystem ffi What steps will reproduce the bug? repro.c #include // Fast-eligible: 2 register arguments, scalar return. Resolving this signature // makes Cre...

X Description: Version main Platform Linux Subsystem ffi What steps will reproduce the bug? repro.c #include <stdint.h> // Fast-eligible: 2 register arguments, scalar return. Resolving this signature // mak...

Opengraph URL: https://github.com/nodejs/node/issues/64968

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: AllocateCodeNear() probes up to 2048 pages with a failing mmap each, costing ~790 µs per trampoline","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nLinux\n```\n\n### Subsystem\n\nffi\n\n### What steps will reproduce the bug?\n\n`repro.c`\n```c\n#include \u003cstdint.h>\n\n// Fast-eligible: 2 register arguments, scalar return. Resolving this signature\n// makes CreateFastFFIMetadata() emit a trampoline through AllocateCodeNear().\nint32_t add2(int32_t a, int32_t b) {\n  return a + b;\n}\n\n// Fast-ineligible baseline: 9 arguments exceeds V8's fast-call cap, so no\n// trampoline is emitted and AllocateCodeNear() is never reached.\nint32_t add9(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f,\n             int32_t g, int32_t h, int32_t i) {\n  return a + b + c + d + e + f + g + h + i;\n}\n```\n\n`repro.js`\n```js\nimport { DynamicLibrary, suffix } from 'node:ffi';\nimport { stat } from 'node:fs/promises';\n\nconst libPath = new URL(`./repro.${suffix}`, import.meta.url).pathname;\nawait stat(libPath);\n\nconst fastEligible = { arguments: ['i32', 'i32'], return: 'i32' };\nconst fastIneligible = { arguments: Array(9).fill('i32'), return: 'i32' };\n\nconst lib = new DynamicLibrary(libPath);\n\nfunction timeResolve(name, signature) {\n  const start = performance.now();\n  lib.getFunction(name, signature);\n  return (performance.now() - start) * 1000;\n}\n\n// Warm up one-time initialization (libffi setup, executable-memory self-test)\n// so it is not attributed to the first measured resolution.\nlib.getFunction('add9', fastIneligible);\nlib.getFunction('add2', fastEligible);\n\n// Same symbol resolution work, but no trampoline is allocated.\nconsole.log(`add9, no trampoline:  ${timeResolve('add9', fastIneligible).toFixed(1)} us`);\nconsole.log(`add2, first probe:    ${timeResolve('add2', fastEligible).toFixed(1)} us`);\n\n// Every fast-eligible resolution allocates another trampoline page next to the\n// library, so the free pages inside AllocateCodeNear()'s +/- 1024 page probe\n// window are steadily consumed. Once they are gone, each allocation walks the\n// whole window, fails every MAP_FIXED_NOREPLACE probe, and takes the plain-mmap\n// fallback it could have taken immediately.\nconst samples = [];\nfor (let i = 0; i \u003c 1200; i++) samples.push(timeResolve('add2', fastEligible));\n\nfor (let i = 0; i \u003c samples.length; i += 200) {\n  const window = samples.slice(i, i + 200);\n  const mean = window.reduce((a, b) => a + b, 0) / window.length;\n  console.log(`add2, resolves ${i + 1}-${i + window.length}: mean ${mean.toFixed(1)} us`);\n}\n\nlib.close();\n```\n\nCommands to run:\n```sh\n$ cc -shared -fPIC -O2 -o repro.so repro.c\n\n$ node --experimental-ffi repro.js\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nResolving a fast-eligible signature costs about as much as a fast-ineligible one, since the extra work is a single page allocation.\n\n### What do you see instead?\n\n```console\nadd9, no trampoline:  29.0 us\nadd2, first probe:    31.1 us\nadd2, resolves 1-200: mean 517.5 us\nadd2, resolves 201-400: mean 657.0 us\nadd2, resolves 401-600: mean 728.0 us\nadd2, resolves 601-800: mean 751.0 us\nadd2, resolves 801-1000: mean 753.1 us\nadd2, resolves 1001-1200: mean 755.4 us\n```\n\nOnce the pages near the library are used up, each fast-eligible resolution costs ~28x a fast-ineligible one, spent entirely on ~2048 `mmap` calls that are all expected to fail.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-08-02T21:39:46Z","url":"https://github.com/nodejs/node/issues/64968"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:695209f2-7003-73a8-394f-0f3f1004dde9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE23A:32386D:635190:80C58D:6AED2AC9
html-safe-nonce5c79b4ed2ba5c133bc7aa7d64c7d2067b1420c7b28e6f1e236b7b2b240b22a86
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjNBOjMyMzg2RDo2MzUxOTA6ODBDNThEOjZBRUQyQUM5IiwidmlzaXRvcl9pZCI6Ijc5NTA3MDAyMDE1MTQ5Njk4MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6b8ee5ea001599c5e542e23680df2692f8c19df2d220f4138f848a7a5d8f7389
hovercard-subject-tagissue:5044584197
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64968/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3725924c95f465d28e681f2940d6dd92c66327a910d7be57cb61faacbf92c515/nodejs/node/issues/64968
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3725924c95f465d28e681f2940d6dd92c66327a910d7be57cb61faacbf92c515/nodejs/node/issues/64968
og:image:altVersion main Platform Linux Subsystem ffi What steps will reproduce the bug? repro.c #include // Fast-eligible: 2 register arguments, scalar return. Resolving this signature // makes Cre...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametrivikr
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
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-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/64968#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F64968
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%2Fissues%2F64968
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/64968
Reloadhttps://github.com/nodejs/node/issues/64968
Reloadhttps://github.com/nodejs/node/issues/64968
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)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
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/64968
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/64968
#64969https://github.com/nodejs/node/pull/64969
ffi: AllocateCodeNear() probes up to 2048 pages with a failing mmap each, costing ~790 µs per trampolinehttps://github.com/nodejs/node/issues/64968#top
#64969https://github.com/nodejs/node/pull/64969
https://github.com/trivikr
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
https://github.com/trivikr
trivikrhttps://github.com/trivikr
on Aug 2, 2026https://github.com/nodejs/node/issues/64968#issue-5044584197
trivikrhttps://github.com/trivikr
on Aug 2, 2026https://github.com/nodejs/node/issues/64968#event-28858722200
trivikrhttps://github.com/trivikr
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
on Aug 2, 2026https://github.com/nodejs/node/issues/64968#event-28858722433
https://github.com/trivikr
trivikrhttps://github.com/trivikr
on Aug 2, 2026https://github.com/nodejs/node/issues/64968#issuecomment-5160531800
#64969https://github.com/nodejs/node/pull/64969
trivikrhttps://github.com/trivikr
on Aug 9, 2026https://github.com/nodejs/node/issues/64968#event-29194928716
ffi: shrink trampoline placement probe windowhttps://github.com/trivikr/node/commit/51a55d4b38f98324bd552026ad4a73e9d7caacc7
51a55d4https://github.com/trivikr/node/commit/51a55d4b38f98324bd552026ad4a73e9d7caacc7
trivikrhttps://github.com/trivikr
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
51a55d4https://github.com/nodejs/node/commit/51a55d4b38f98324bd552026ad4a73e9d7caacc7
on Aug 9, 2026https://github.com/nodejs/node/issues/64968#event-29194934034
aduh95https://github.com/aduh95
on Aug 13, 2026https://github.com/nodejs/node/issues/64968#event-29399897985
ffi: shrink trampoline placement probe windowhttps://github.com/nodejs/node/commit/67aaafa9a9d459ad80ccdb0d127c3200afb05d1a
67aaafahttps://github.com/nodejs/node/commit/67aaafa9a9d459ad80ccdb0d127c3200afb05d1a
aduh95https://github.com/aduh95
on Aug 25, 2026https://github.com/nodejs/node/issues/64968#event-30010531158
ffi: shrink trampoline placement probe windowhttps://github.com/nodejs/node/commit/8b0bdd931ce2321a8bf3c269889a34d4aa5b0a23
8b0bdd9https://github.com/nodejs/node/commit/8b0bdd931ce2321a8bf3c269889a34d4aa5b0a23
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/64968
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/64968
trivikrhttps://github.com/trivikr
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
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.