René's URL Explorer Experiment


Title: perf: guard ObjectTable with a monitor instead of StampedLock by edusperoni · Pull Request #2103 · NativeScript/android · GitHub

Open Graph Title: perf: guard ObjectTable with a monitor instead of StampedLock by edusperoni · Pull Request #2103 · NativeScript/android

X Title: perf: guard ObjectTable with a monitor instead of StampedLock by edusperoni · Pull Request #2103 · NativeScript/android

Description: Description ObjectTable (added in #2099) guarded its tables with java.util.concurrent.locks.StampedLock: write locks for mutations, optimistic reads elsewhere. On device, StampedLock runs interpreted. It lives in the boot classpath (core-oj) but outside the boot image, and an app's baseline profile can't compile boot-classpath methods. A profile of NativeScript core's apps/automated suite showed StampedLock.tryWriteLock/casState/writeLock/unlockWriteInternal running in the interpreter on the main thread. This replaces it with synchronized (this). An uncontended monitor enter/exit is compiled into every caller. Reads now take the lock too, so the torn-read handling the optimistic path needed (findIdUnlocked, getUnlocked) is gone. A second commit makes the table concurrent on every API level. It was limited to API 24+ only because StampedLock needs it. On API 21–23, argument objects were resolved natively under the isolate lock and new ids took a separate path; now every level registers through findOrRegister. findIdOptimistic is merged into findId, and getOrCreateObjectId takes one lock instead of a lookup followed by a registration. JNI microbenchmarks (debug.ns.jnibench, optimized release, SM-G780G; main and this branch interleaved, 2 passes × 3 runs; median ns): Benchmark main this PR new java.lang.Object() 2763 1528 −45% (6/6 runs faster) lifecycle new java.lang.Object() [alloc, kept alive] 2807 1520 −46% lifecycle JniBench.newObjectInJava() [alloc, kept alive] 2015 1094 −46% static.newObjectOfManyClasses() [16 classes] 1683 1097 −35% static.newObjectInJava() [new wrapper] 1276 954 −25% static.newInstance(extended class) [Java-created] 8974 7419 −17% new Object.extend({})() 3975 3740 −6% contention, 1 thread, no args 3608 2153 −40% callback.noArgs() 479 436 −9% contention, 2 threads, 3 new objects 6101 6305 +3% (1/6) contention, 2 threads, 3 new objects of 16 classes 6295 6487 +3% (0/6) contention, 4 threads, 3 existing objects 3343 3546 +6% (0/6) The other rows are within ±2%. Even after the JIT has compiled it, StampedLock's write path was costly. Known trade-off: when 2–4 Java threads call into JS at the same time, their object-id lookups used to be lock-free optimistic reads and now contend on the monitor: +3..+6% in those benchmarks. Apps run JS on one thread in the common case, where this is a clear win. Real apps: no measurable difference on the template app's cold start (497/491 vs 503/494 ms) or on a 1000-tile flex-wrap mount. The phone was thermally throttling during that comparison, so those numbers only rule out a large effect. Does your commit message include the wording below to reference a specific issue in this repo? No issue. Related Pull Requests #2099 introduced ObjectTable. Does your pull request have unit tests? Yes. The ObjectTable JVM test for concurrent readers and a writer now requires every read of a stable entry to hit; it used to allow optimistic misses. The test for disabled optimistic reads is gone with the flag. JVM tests: 29/29. Full device suite: API 36 emulator: 1551 specs, 0 failures. API 23 emulator (arm64): 1551 specs, 3 failures, the same 3 that main fails on that emulator: a proxy test that matches ByteBuffer.toString()'s newer cap= format; two HTTP module-import tests that time out. On API 23 the harness also reports "App has crashed - ErrorReportActivity" for both main and this PR. run-as ... ls exits 0 there even when the file is missing, so the harness's checks misfire; the results were read from the XML directly. Summary by CodeRabbit Bug Fixes Improved the reliability of object lookups when multiple threads access the runtime, helping ensure stable objects return the correct identifiers. Object registration, lookup, retrieval, and removal now use consistent synchronization, reducing the risk of inconsistent results during concurrent access. Updated object argument handling to register objects without an existing identifier and correctly mark newly registered objects.

Open Graph Description: Description ObjectTable (added in #2099) guarded its tables with java.util.concurrent.locks.StampedLock: write locks for mutations, optimistic reads elsewhere. On device, StampedLock runs interpret...

X Description: Description ObjectTable (added in #2099) guarded its tables with java.util.concurrent.locks.StampedLock: write locks for mutations, optimistic reads elsewhere. On device, StampedLock runs interpret...

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

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:4dab37ca-3602-c4de-65a3-ab49114dc593
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id899C:3D97C8:15F106F:1D31969:6B013850
html-safe-noncea6ca885b3ced2ba408703fd5abd775f8de12786542b329f1470b0a7a8e18130b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTlDOjNEOTdDODoxNUYxMDZGOjFEMzE5Njk6NkIwMTM4NTAiLCJ2aXNpdG9yX2lkIjoiMjAzNzUyNTIzMjgxNzg3OTEyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8ebec1ca46cebb30be4c8e1c92f02f8f5babd759234021704c9b7ee8fa68ea28
hovercard-subject-tagpull_request:5260937306
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/2103/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 ObjectTable (added in #2099) guarded its tables with java.util.concurrent.locks.StampedLock: write locks for mutations, optimistic reads elsewhere. On device, StampedLock runs interpret...
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/2103/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F2103%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%2F2103%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/2103/files
Reloadhttps://github.com/NativeScript/android/pull/2103/files
Reloadhttps://github.com/NativeScript/android/pull/2103/files
NativeScripthttps://github.com/NativeScript
androidhttps://github.com/NativeScript/android
Codehttps://github.com/NativeScript/android
Issues106 (106)https://github.com/NativeScript/android/issues
Pull requests24 (24)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/objecttable-synchronizedhttps://github.com/NativeScript/android/tree/perf/objecttable-synchronized
Conversation 1 https://github.com/NativeScript/android/pull/2103
Commits 2 https://github.com/NativeScript/android/pull/2103/commits
Checks 8 https://github.com/NativeScript/android/pull/2103/checks
Files changed https://github.com/NativeScript/android/pull/2103/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2103/files
perf: guard ObjectTable with a monitor instead of StampedLock https://github.com/NativeScript/android/pull/2103/files#top
Show all changes 2 commits https://github.com/NativeScript/android/pull/2103/files
7f7ad3a perf: guard ObjectTable with a monitor instead of StampedLock edusperoni Nov 11, 2026 https://github.com/NativeScript/android/pull/2103/commits/7f7ad3a1b717c84fc2d2fd2d72c4e42bc89eadf6
fee28fb perf: register objects concurrently on every API level edusperoni Nov 11, 2026 https://github.com/NativeScript/android/pull/2103/commits/fee28fb3e598cafe93351f56544ffb599b654b9d
Clear filters https://github.com/NativeScript/android/pull/2103/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2103/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2103/files
ObjectTable.java https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
Runtime.java https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
ObjectTableTest.java https://github.com/NativeScript/android/pull/2103/files#diff-25dab41a4ffbbdcee58c1077e85cda611c32826f9c6be6411c5f04313cd98ae1
test-app/runtime/src/main/java/com/tns/ObjectTable.javahttps://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
View file https://github.com/NativeScript/android/blob/fee28fb3e598cafe93351f56544ffb599b654b9d/test-app/runtime/src/main/java/com/tns/ObjectTable.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2103/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
https://github.com/NativeScript/android/pull/2103/files#diff-33d4dbc945da122f3865e371aad3c0526854321ac8d5fc0aacc045fd11c6fca3
test-app/runtime/src/main/java/com/tns/Runtime.javahttps://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
View file https://github.com/NativeScript/android/blob/fee28fb3e598cafe93351f56544ffb599b654b9d/test-app/runtime/src/main/java/com/tns/Runtime.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/2103/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
https://github.com/NativeScript/android/pull/2103/files#diff-cf9bb4e9ca1a476cacd6e270fc8bcd12c71f89d52d272915bc99df57b3581f59
Please reload this pagehttps://github.com/NativeScript/android/pull/2103/files
Please reload this pagehttps://github.com/NativeScript/android/pull/2103/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.