René's URL Explorer Experiment


Title: perf: smaller metadata, mapped instead of copied by edusperoni · Pull Request #2112 · NativeScript/android · GitHub

Open Graph Title: perf: smaller metadata, mapped instead of copied by edusperoni · Pull Request #2112 · NativeScript/android

X Title: perf: smaller metadata, mapped instead of copied by edusperoni · Pull Request #2112 · NativeScript/android

Description: Description Makes the metadata smaller and cheaper to load, without changing how wide node ids are. That decision is left for a follow-up; this is the part that only shrinks things. Size (test app): Before After treeValueStream.dat, debug build 1,635 KB 1,209 KB −26% all three streams, debug build 3,264 KB 2,838 KB −13% all three streams, release build 2,843 KB 2,469 KB −13% all three streams, zlib 1,052 KB 1,050 KB ≈ 0 release APK 34,934 KB 34,931 KB −3 KB The download does not get smaller: the redundancy removed here is what the APK's compression was already removing. The saving is on disk after extraction and in memory. What changed in the value stream (the other two streams are untouched): Signatures are stored once. 84,677 method records shared 18,833 distinct signatures, each written out in full every time. They now live in a region at the head of the stream, and a method refers to its signature by offset. A method record is a fixed 7 bytes: the name offset and a 3-byte signature reference whose low bit is the resolved flag. It was 7 bytes plus 2 per type, about 11 on average. A class value has one byte saying which of its six member sections exist, instead of a 2-byte count for each. 79% of those counts were zero. A static field names its declaring type only when it is not the class listing it. That was the case for 15% of them. An interface no longer carries the offset of the com/tns/gen/ prefix, a constant the runtime already has. An array's element node no longer gets a class value that nothing could reach. The stream opens with a format word. The generator and the runtime ship together, so a mismatch means stale or damaged metadata; it used to be misread, and is now logged (The app's metadata is not in the format this runtime reads…) and startup is aborted. One new limit: a signature reference has 23 bits, so the signature region can be at most 8 MB. It is 127 KB here; the generator fails the build past the limit. Runtime side: MethodInfo is a pointer to its record. It no longer copies each signature into a std::vector when a class is materialized (one heap allocation per method with parameters, and again on every copy of the entry); the signature is read when the method is first resolved. The names and values streams are mapped read-only instead of being read into heap buffers kept for the life of the process, each with 512 KB of slack. Their pages are the file's own clean ones, which the system can drop under memory pressure. The whole file is read ahead and populated up front: left to fault in lazily, the loading cost moved onto the first access of each class and made it noisier, and populating without the read-ahead made a cold start slower than fread. Nothing writes to those buffers any more. A type resolved at run time used to put a 3-byte record in the value buffer just so its node had an offset. SetMissingBaseMethods is removed (first commit). Since extension functions were added to the format it has read the extension function count as the instance method count, so it has added nothing for any type without extension functions, and would misread the entries of one that has them. Measurements, optimized release build, medians. "First access" is the sum of the harness's 17 cold rows (android.view.View, android.widget.TextView, android.app.Activity, the android.R classes, first calls of 20 View methods), one sample per launch. Galaxy S20 FE, Android 13, warm starts (16 launches before, 8 after): Before Format only Format + mapping native metadata load 2,404 µs 2,112 µs 1,370 µs first access, total 6,459 µs 6,359 µs 6,228 µs native heap (PSS) 10,606 KB 9,916 KB 7,607 KB mapped files (PSS) 20 KB 20 KB 2,312 KB total PSS 53,744 KB 52,799 KB 52,555 KB API 36 emulator, cold starts with the page cache dropped before each launch (12 launches each): Before Format + mapping native metadata load 3,130 µs 2,201 µs first access, total 3,084 µs 2,897 µs The first-access differences are within run-to-run noise; the claim is that it is not slower. The load time and heap differences are well outside it. Cold starts could not be measured on the phone (no root to drop the page cache). Not in this PR: Node id width, and with it the 65,535-node limit. The format check throws from MetadataNode::BuildMetadata, which Runtime::UnwindFailedInit unwinds. With an old-format stream planted on the emulator, two of three launches then ended in a SIGSEGV inside Runtime::DestroyRuntime rather than a clean exit. The mismatch is logged before that either way. That teardown path is not touched here. The tree is still built eagerly at startup. Does your commit message include the wording below to reference a specific issue in this repo? No issue. Related Pull Requests #2111 moved runtime-created nodes out of the static tree, which is what lets the value buffer be read-only here. Does your pull request have unit tests? No new specs: the format has no behaviour of its own to assert, and every existing spec reads it. ./gradlew runtestsAndVerifyResults passes 1598 / 1598 after the format commit, after the mapping commit and on the final tree. The generator's output is byte-identical across three clean builds. The generated stream was also checked with a parser written separately from the format description: it walks every node, validates each name offset, type id and signature reference, and requires every byte of the value stream to belong to exactly one record. The member counts it finds match the old format's exactly. The generator has no unit tests for its writer, and none are added here. Summary by CodeRabbit Reliability Incompatible or malformed metadata is now reported as an error rather than processed, with additional checks for incomplete metadata files. Metadata loading now validates the structure of its data before building runtime metadata, helping prevent failures from invalid input. Compatibility Updated metadata handling supports the latest metadata format and more consistent access to method signatures, class members, and type information.

Open Graph Description: Description Makes the metadata smaller and cheaper to load, without changing how wide node ids are. That decision is left for a follow-up; this is the part that only shrinks things. Size (test app)...

X Description: Description Makes the metadata smaller and cheaper to load, without changing how wide node ids are. That decision is left for a follow-up; this is the part that only shrinks things. Size (test app)...

Opengraph URL: https://github.com/NativeScript/android/pull/2112

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e149d5b1-626f-8a96-ab0e-f920f9f772d4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDD30:34DB8F:1EC2A2B:2911221:6B017DD9
html-safe-nonce1c9f0ac20182bad660a2f3904bf1d17d9fe8efacb7b5d213d33168519fba8386
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDMwOjM0REI4RjoxRUMyQTJCOjI5MTEyMjE6NkIwMTdERDkiLCJ2aXNpdG9yX2lkIjoiNzYzMDM2NTI2Njk0OTUzNzI0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac302f401f6e6ac80d490f43c95d85ddfcf0ec40f8e73c7fcf3ba546a121a283ae
hovercard-subject-tagpull_request:5342425284
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/NativeScript/android/pull/2112/files
twitter:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
og:image:altDescription Makes the metadata smaller and cheaper to load, without changing how wide node ids are. That decision is left for a follow-up; this is the part that only shrinks things. Size (test app)...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/android git https://github.com/NativeScript/android.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id29137950
octolytics-dimension-repository_nwoNativeScript/android
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id29137950
octolytics-dimension-repository_network_root_nwoNativeScript/android
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/android/pull/2112/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F2112%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%2FNativeScript%2Fandroid%2Fpull%2F2112%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=NativeScript%2Fandroid
Reloadhttps://github.com/NativeScript/android/pull/2112/files
Reloadhttps://github.com/NativeScript/android/pull/2112/files
Reloadhttps://github.com/NativeScript/android/pull/2112/files
NativeScripthttps://github.com/NativeScript
androidhttps://github.com/NativeScript/android
Codehttps://github.com/NativeScript/android
Issues106 (106)https://github.com/NativeScript/android/issues
Pull requests26 (26)https://github.com/NativeScript/android/pulls
Actionshttps://github.com/NativeScript/android/actions
Projectshttps://github.com/NativeScript/android/projects
Wikihttps://github.com/NativeScript/android/wiki
Security and qualityhttps://github.com/NativeScript/android/security
Insightshttps://github.com/NativeScript/android/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose
edusperonihttps://github.com/edusperoni
mainhttps://github.com/NativeScript/android/tree/main
perf/metadata-format-v2https://github.com/NativeScript/android/tree/perf/metadata-format-v2
Conversation 1 https://github.com/NativeScript/android/pull/2112
Commits 5 https://github.com/NativeScript/android/pull/2112/commits
Checks 8 https://github.com/NativeScript/android/pull/2112/checks
Files changed https://github.com/NativeScript/android/pull/2112/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/files
perf: smaller metadata, mapped instead of copied https://github.com/NativeScript/android/pull/2112/files#top
Show all changes 5 commits https://github.com/NativeScript/android/pull/2112/files
973494d refactor: remove SetMissingBaseMethods edusperoni Nov 16, 2026 https://github.com/NativeScript/android/pull/2112/commits/973494db10060a15117e529b5e3633808c8dbc79
2631217 perf: pack the metadata value stream edusperoni Nov 16, 2026 https://github.com/NativeScript/android/pull/2112/commits/26312171cfc69fa4c63eff7114f8c954cb209619
2488d7f perf: map the metadata instead of reading it into the heap edusperoni Nov 16, 2026 https://github.com/NativeScript/android/pull/2112/commits/2488d7fbde9826c163a9962520b359b7621fa2a3
e1fc47a perf: read the metadata ahead and map it up front edusperoni Nov 16, 2026 https://github.com/NativeScript/android/pull/2112/commits/e1fc47a9f16919b88e80d71b507a3dea45c790e7
08802ad fix: log a metadata format mismatch edusperoni Nov 16, 2026 https://github.com/NativeScript/android/pull/2112/commits/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663
Clear filters https://github.com/NativeScript/android/pull/2112/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/files
Writer.java https://github.com/NativeScript/android/pull/2112/files#diff-151a348a396794774e4863b0978d64014246af7db29b0bc7d77f11dd1d60ca00
MetadataEntry.cpp https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
MetadataFieldInfo.h https://github.com/NativeScript/android/pull/2112/files#diff-f44065889bddc80dcce1a56a4111026f1f54399cbc7ce32627bd8382d52a9185
MetadataMethodInfo.cpp https://github.com/NativeScript/android/pull/2112/files#diff-a24395ea5e1f9412b39c84b73180767e9a3680e9365cdc9e50a44bc693dc68a6
MetadataMethodInfo.h https://github.com/NativeScript/android/pull/2112/files#diff-d8225038e63b089395e1b111fe3de8a73996f744d8f2d388a79ac6881f7bd039
MetadataNode.cpp https://github.com/NativeScript/android/pull/2112/files#diff-6f6c5b64f60875e24b75b8a21b3164f114822aa7e5add5755f072f36403f7f8b
MetadataNode.h https://github.com/NativeScript/android/pull/2112/files#diff-ac7f7c34025389ca6f1145667245073945ad1bc6b2b1285a05bf4d084924f091
MetadataReader.cpp https://github.com/NativeScript/android/pull/2112/files#diff-c10689703cc3f34ede1d9fe01cad25579a071758c828e86ad0cad3d9e179bb1e
MetadataReader.h https://github.com/NativeScript/android/pull/2112/files#diff-4fda5fc04e9fe4f5478ca473515ea8d2af62f9187b876614daaa2d023c459104
test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.javahttps://github.com/NativeScript/android/pull/2112/files#diff-151a348a396794774e4863b0978d64014246af7db29b0bc7d77f11dd1d60ca00
View file https://github.com/NativeScript/android/blob/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663/test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/files
test-app/runtime/src/main/cpp/MetadataEntry.cpphttps://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
View file https://github.com/NativeScript/android/blob/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663/test-app/runtime/src/main/cpp/MetadataEntry.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2112/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
https://github.com/NativeScript/android/pull/2112/files#diff-0718eb1bcaf4f9e7d7a058c31337b126e8a0309423907daa64d8a607631e86cb
test-app/runtime/src/main/cpp/MetadataFieldInfo.hhttps://github.com/NativeScript/android/pull/2112/files#diff-f44065889bddc80dcce1a56a4111026f1f54399cbc7ce32627bd8382d52a9185
View file https://github.com/NativeScript/android/blob/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663/test-app/runtime/src/main/cpp/MetadataFieldInfo.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2112/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2112/files#diff-f44065889bddc80dcce1a56a4111026f1f54399cbc7ce32627bd8382d52a9185
https://github.com/NativeScript/android/pull/2112/files#diff-f44065889bddc80dcce1a56a4111026f1f54399cbc7ce32627bd8382d52a9185
test-app/runtime/src/main/cpp/MetadataMethodInfo.cpphttps://github.com/NativeScript/android/pull/2112/files#diff-a24395ea5e1f9412b39c84b73180767e9a3680e9365cdc9e50a44bc693dc68a6
View file https://github.com/NativeScript/android/blob/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663/test-app/runtime/src/main/cpp/MetadataMethodInfo.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2112/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2112/files#diff-a24395ea5e1f9412b39c84b73180767e9a3680e9365cdc9e50a44bc693dc68a6
https://github.com/NativeScript/android/pull/2112/files#diff-a24395ea5e1f9412b39c84b73180767e9a3680e9365cdc9e50a44bc693dc68a6
test-app/runtime/src/main/cpp/MetadataMethodInfo.hhttps://github.com/NativeScript/android/pull/2112/files#diff-d8225038e63b089395e1b111fe3de8a73996f744d8f2d388a79ac6881f7bd039
View file https://github.com/NativeScript/android/blob/08802adb8ce100a7ee5e2914e89e0bc8dcf1d663/test-app/runtime/src/main/cpp/MetadataMethodInfo.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2112/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2112/files#diff-d8225038e63b089395e1b111fe3de8a73996f744d8f2d388a79ac6881f7bd039
https://github.com/NativeScript/android/pull/2112/files#diff-d8225038e63b089395e1b111fe3de8a73996f744d8f2d388a79ac6881f7bd039
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2112/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.