Skip to content

test(android): add JNI bridge cases to the marshalling benchmark - #120

Open
ammarahm-ed wants to merge 1 commit into
fix/android-v8-module-cleanupfrom
perf/jni-01-benchmarks
Open

ammarahm-ed wants to merge 1 commit into
fix/android-v8-module-cleanupfrom
perf/jni-01-benchmarks

Conversation

@ammarahm-ed

@ammarahm-ed ammarahm-ed commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the cases the JNI bridge PRs stacked on this one change. It also fixes the suite's unit: it printed ms / n * 1000, which is microseconds per call, under an ns/call label.

New cases, in org.nativescript.Benchmarks and marshalling-benchmark.js:

  • Instance call with arguments: add(int, int).
  • Strings: a non-ASCII string round trip, a 1 KB string round trip, and a char return.
  • Objects: returning this, returning a new object, and calling a method on a new object.
  • Arrays: passing 16-element int[] and double[] arrays.
  • Callbacks: a callback with two int arguments that returns an int, and a callback with a String argument.

Baseline

These are this branch's numbers, which every PR above compares against. Device: Sony SO-01M (Android 11, arm64). Release APK built with -PonlyArm64 -PnsBytecodeDisabled, AOT-compiled with cmd package compile -m speed. One warm-up launch is discarded, then 5 launches with --ez bench true; values are the median ns per call.

Case V8, Node-API V8, direct
Instance add(a, b) 1,186 1,135
Pass and return non-ASCII string 2,457 2,444
Pass and return 1KB string 7,395 6,667
Return a Char 958 481
Return this 1,616 1,630
Return a new object 33,642 23,862
Call a method on a new object 42,810 34,684
Pass a 16 Int Array 4,744 5,371
Pass a 16 Double Array 5,316 5,785
Invoke int callback 13,217 10,889
Invoke string callback 10,233 8,518

Native heap after one pass of the suite: 485 MB on Node-API and 180 MB on the direct runtime. Almost all of it is wrappers for returned Java objects that are never released.

Run-to-run noise is about ±5% on the primitive cases and ±15% on the allocation-heavy ones (array returns and object returns).

Running it

./gradlew :app:assembleRelease -PonlyArm64 -Pengine=V8 -PbindingLayer=napi -PnsBytecodeDisabled
adb install -r app/build/outputs/apk/release/app-release.apk
adb shell cmd package compile -m speed -f com.tns.testapplication
adb shell am start -n com.tns.testapplication/com.tns.NativeScriptActivity --ez bench true
adb logcat | grep NS_ENGINE_BENCHMARK

@ammarahm-ed
ammarahm-ed added this pull request to stack #121 November 9, 2026 06:06
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bcfa4fd4-cb0c-4cef-8196-0aafcce9573d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant