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-profiling | 0 |
| react-import-map | react,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-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e149d5b1-626f-8a96-ab0e-f920f9f772d4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DD30:34DB8F:1EC2A2B:2911221:6B017DD9 |
| html-safe-nonce | 1c9f0ac20182bad660a2f3904bf1d17d9fe8efacb7b5d213d33168519fba8386 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDMwOjM0REI4RjoxRUMyQTJCOjI5MTEyMjE6NkIwMTdERDkiLCJ2aXNpdG9yX2lkIjoiNzYzMDM2NTI2Njk0OTUzNzI0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 302f401f6e6ac80d490f43c95d85ddfcf0ec40f8e73c7fcf3ba546a121a283ae |
| hovercard-subject-tag | pull_request:5342425284 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | ///pull_requests/show/files |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/android/pull/2112/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | 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)... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Skip to content | https://github.com/NativeScript/android/pull/2112/files#start-of-content |
| https://github.com/ |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F2112%2Ffiles |
| GitHubRepository hosting, code review, and collaboration | https://github.com/platform |
| CopilotAI coding agent for tasks, projects, and automated work | https://github.com/features/copilot |
| ActionsCI/CD and automation | https://github.com/features/actions |
| Code QualityQuality analysis, fixes, and enforcement | https://github.com/features/code-quality |
| CodespacesCloud development environments | https://github.com/features/codespaces |
| Code SecurityVulnerability detection and remediation | https://github.com/security/advanced-security/code-security |
| Secret ProtectionSecret scanning and leak prevention | https://github.com/security/advanced-security/secret-protection |
| All Features | https://github.com/features |
| Documentation | https://docs.github.com/en |
| Training | https://learn.github.com/skills |
| Certifications | https://learn.github.com/credentials |
| Build with Copilot | https://github.com/features/ai |
| Customize Copilot | https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview |
| Integrations | https://github.com/marketplace |
| Trending repos | https://github.com/trending |
| GitHub Sponsors | https://github.com/open-source/sponsors |
| Developer articles | https://github.com/resources/articles |
| ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place. | https://github.blog/changelog/ |
| Enterprises | https://github.com/enterprise |
| Team | https://github.com/team |
| Startups | https://github.com/enterprise/startups |
| Nonprofits | https://github.com/solutions/industry/nonprofits |
| Healthcare | https://github.com/solutions/industry/healthcare |
| Financial services | https://github.com/solutions/industry/financial-services |
| Manufacturing | https://github.com/solutions/industry/manufacturing |
| Government | https://github.com/solutions/industry/government |
| See all industries | https://github.com/solutions/industry |
| Why GitHub | https://github.com/why-github |
| Customer Stories | https://github.com/customer-stories |
| Business insights | https://github.com/solutions/executive-insights |
| Trust Center | https://github.com/trust-center |
| GitHub Advanced SecurityEnterprise-grade code security | https://github.com/security/advanced-security |
| Copilot for businessEnterprise-grade AI features | https://github.com/features/copilot/copilot-business |
| Premium SupportEnterprise-grade 24/7 support | https://github.com/enterprise/premium-support |
| Documentation | https://docs.github.com/en |
| Resource center | https://github.com/resources |
| Blog | https://github.blog/ |
| Events & webinars | https://github.com/resources/events |
| Community Forum | https://github.com/orgs/community/discussions |
| Customer Stories | https://github.com/customer-stories |
| Integrations | https://github.com/marketplace |
| Customer support | https://help.github.com/ |
| Training | https://learn.github.com/skills |
| GitHub Status | https://www.githubstatus.com/ |
| About | https://github.com/about |
| Partners | https://github.com/partners |
| Changelog | https://github.blog/changelog/ |
| GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub. | https://githubuniverse.com/ |
| Pricing | https://github.com/pricing |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F2112%2Ffiles |
| Sign up | https://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 |
| Reload | https://github.com/NativeScript/android/pull/2112/files |
| Reload | https://github.com/NativeScript/android/pull/2112/files |
| Reload | https://github.com/NativeScript/android/pull/2112/files |
| NativeScript | https://github.com/NativeScript |
| android | https://github.com/NativeScript/android |
| Code | https://github.com/NativeScript/android |
| Issues106 (106) | https://github.com/NativeScript/android/issues |
| Pull requests26 (26) | https://github.com/NativeScript/android/pulls |
| Actions | https://github.com/NativeScript/android/actions |
| Projects | https://github.com/NativeScript/android/projects |
| Wiki | https://github.com/NativeScript/android/wiki |
| Security and quality | https://github.com/NativeScript/android/security |
| Insights | https://github.com/NativeScript/android/insights |
| Sign up for GitHub
| https://github.com/signup?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose |
| terms of service | https://docs.github.com/terms |
| privacy statement | https://docs.github.com/privacy |
| Sign in | https://github.com/login?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose |
| edusperoni | https://github.com/edusperoni |
| main | https://github.com/NativeScript/android/tree/main |
| perf/metadata-format-v2 | https://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 page | https://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 page | https://github.com/NativeScript/android/pull/2112/files |
| Please reload this page | https://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.java | https://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 page | https://github.com/NativeScript/android/pull/2112/files |
| test-app/runtime/src/main/cpp/MetadataEntry.cpp | https://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.h | https://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.cpp | https://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.h | https://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 page | https://github.com/NativeScript/android/pull/2112/files |
| Please reload this page | https://github.com/NativeScript/android/pull/2112/files |
|
| https://github.com |
| Terms | https://docs.github.com/site-policy/github-terms/github-terms-of-service |
| Privacy | https://docs.github.com/site-policy/privacy-policies/github-privacy-statement |
| Security | https://github.com/security |
| Status | https://www.githubstatus.com/ |
| Community | https://github.community/ |
| Docs | https://docs.github.com/ |
| Contact | https://support.github.com?tags=dotcom-footer |
Viewport: width=device-width
URLs of crawlers that visited me.