[PR #4791] [MERGED] perf(android): filter class pages before bridge serialization #6412

Closed
opened 2026-10-31 01:14:16 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4791
Author: @N0zoM1z0
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @N0zoM1z0

Base: main ← Head: perf/android-class-filter-4776


📝 Commits (3)

  • 4249918 perf(android): filter class pages before bridge serialization
  • 163393c perf(android): continue class pages from examined inventory positions
  • cbecc62 chore: merge main into Android class filtering

📊 Changes

16 files changed (+361 additions, -73 deletions)

View changed files

📝 bridge/android/ReaJadxBridge.java (+28 -12)
📝 docs/android-analysis.md (+8 -4)
📝 scripts/verify/android/analysis.mjs (+2 -0)
➕ scripts/verify/android/class-search.mjs (+45 -0)
📝 scripts/verify/android/metadata.mjs (+7 -0)
📝 src/android/JadxAnalysis.ts (+22 -23)
📝 src/android/JadxProtocol.ts (+3 -1)
📝 src/android/JadxRelease.ts (+1 -1)
📝 src/application/android/AndroidSearchEvidenceSummary.ts (+6 -8)
📝 src/contracts/android/androidToolContracts.ts (+1 -1)
📝 tests/boundary/android/JadxAnalysis.test.ts (+142 -0)
📝 tests/boundary/process/androidAnalysisMcp.test.ts (+4 -3)
📝 tests/boundary/process/androidSearchEvidenceBudget.test.ts (+25 -7)
📝 tests/boundary/process/jadxIntegration.test.ts (+8 -6)
📝 tests/conformance/android/ReaJadxMetadataRegression.java (+39 -0)
📝 tests/fixtures/android/jadx-mcp.mjs (+20 -7)

📄 Description

Summary

Fixes #4776. Select Android class names inside the JADX bridge before serialization. Previously a focused NewPipe query returned two matches but transferred all 7,096 names and emitted ~383 KB of complete CLI Evidence.

Change and scope

The existing session-owned inventory supplies matching rows and a next inventory position. Later pages resume there, so complete searches scan once without another index or result cache. The adapter validates contiguous examined ranges, global counts, scope, page identity and selection before declaring completeness. Original query, ordering, duplicate counts, APK/engine identity and complete producer replies survive; empty query still inventories all top-level names. Bridge arguments are parsed once.

Semantic owner: native bridge; CLI/MCP share the provider. Existing snapshot freshness, JVM bounds and cleanup remain authoritative. Private bridge protocol 2 uses the unmodified JADX headless 0.7.1 JAR. Public input/output shapes remain unchanged; the description clarifies top-level scope. Complete raw Evidence now contains selected pages. No generated outputs committed. Existing static APK scope: reads selected data, launches an owned JVM and writes private temporary files; no APK execution, device interaction or original-byte mutation. Additional maintainer scope decision: not applicable.

Executed performance evidence

Pinned comparison: e5ee3ac65 versus cursor fix 163393c11; merged main bd3210eb2 into head cbecc6217 afterward, without changing the measured JADX source. Linux x86-64, Temurin 21, official NewPipe 0.29.1 / ApiDemos 6.0.18. Serial runs on one CPU, 768 MiB JVM heap, 4 GiB family cap, fresh JVM/session, OS caches warm/uncontrolled. Normalized matches/order/duplicates/full inventories agree; original APK hashes and cleanup verified, OOM 0.

Workflow NewPipe before → after ApiDemos before → after
Default complete CLI stdout bytes 383,302 →3,658 134,960 →3,558
CLI stdout estimated tokens 80,140 →984 29,259 →953
Seven warm MCP queries (two sessions/revision) 1,015–1,116 →782–785 ms 1,059–1,202 →849–1,048 ms
Cold CLI wall (two runs/revision) 18.1–18.7 →19.5 s 14.3–15.7 →14.8–15.1 s
Cold CLI CPU / family peak 17.8–18.3 →19.2 s /988–994 →981–987 MiB 14.0–15.4 →14.5–14.8 s /832 →830–832 MiB

Token estimates use pinned tiktoken 0.14 / cl100k on full stdout; commands add 72–84 tokens. Actual model usage, help discovery, prompts, reasoning and tool framing unmeasured. MCP already summarizes: no material MCP token reduction. Including discovery of all 207 tools, orientation workflows estimate 832,839–832,865→831,921–831,967(NewPipe) and 821,755–821,797→822,093–822,099(ApiDemos); catalog 802,821→802,823 tokens. Raw envelopes count text/structured copies; real client exposure unknown.

Whole MCP harness (discovery, orientation, broad/full correctness oracles, cleanup): NewPipe wall 28.9–40.4→31.6 s / CPU 28.5–39.7→31.1–31.2 s / peak 1,514–1,516→1,509–1,518 MiB; ApiDemos wall 25.3–26.8→25.7–27.1 s / CPU 24.9–26.5→25.4–26.8 s / peak 1,440–1,446→1,435–1,442 MiB. Peaks are kernel process-family memory including file cache, not RSS. No stable whole-task CPU/memory gain. NewPipe cold CLI was 5–8% slower in these samples; cause not isolated, and no startup speedup is claimed. Broad-query control: seven warm calls1.613→1.651 s, one session/revision; no general broad speedup established.

Post-main public MCP workflows also pass for both APKs with identical normalized digests: NewPipe 30.3 s wall/29.6 s CPU/1,574 MiB peak; ApiDemos 26.4 s/26.1 s/1,358 MiB. Current main's catalog is 802,937 estimated tokens; complete orientation workflow estimates 832,067/822,203. Separate instrumented shared-service diagnostic (one pair, not public CLI timing) shows native initialization 3.58→3.42 s and load 10.70→10.63 s; it does not explain the observed CLI cold difference.

Validation

Merged as 2d84c800bc51dc865fcabdd3e28cda3d2f4413e7. Verified again in a separate checkout of that actual commit (including intervening main Electron/ELF/README changes): runtime rebuild plus 78 focused tests passed (190.0 s wall/186.1 s CPU/2,813 MiB family peak, 8 GiB cap); real NewPipe production MCP orientation/broad/full-inventory workflow passed (34.4 s/32.1 s/1,698 MiB); real ApiDemos default CLI output passed against the pinned baseline (14.5 s/14.1 s/839 MiB). Native smoke runs kept the original 4 GiB/one-CPU/768 MiB JVM settings. Original APK hashes unchanged, all runs verified owned cleanup and zero OOM events. Both requested co-author trailers are present on the squash commit.

PR-head CI: all 41 enabled checks passed; exact-head Greptile 5/5, both review findings fixed/resolved. CLI token savings are offline estimates; no actual model usage, startup speedup or general whole-task CPU/memory benefit claimed. Separate Apktool repeated resource decoding proposal remains #4777.

  • Focused four Android boundary files — 78 passed; sparse multi-page cursors, duplicates, malformed/non-progressing ranges, empty inventory, retention, lifecycle and failure provenance. Passed again on merged head cbecc6217 (162.3 s wall / 158.2 s CPU / 2,788 MiB peak).
  • Full real node scripts/verify/android/analysis.mjs —passed on 163393c11: five CLI/MCP operations/parity, metadata/overloads/initializers/cross-DEX invokes, actual-Java limits 17/1 and nonzero offsets against native inventory, literal/Unicode/NUL/lone-surrogate selectors, cancellation and readiness/failure recovery. 347.4 s wall / 343.8 s CPU / 1,915 MiB peak; 8 GiB cap / 512 MiB heap / one CPU, cleanup verified/OOM 0.
  • npm run check — passed on merged head cbecc6217, including cache-miss full typecheck, lint/format/knip/metadata and architecture checks. 222.7 s wall / 218.1 s CPU / 4,153 MiB peak; 8 GiB cap, cleanup verified/OOM 0. Earlier 4 GiB attempt guard-stopped and is excluded.
  • npm run docs:check — passed on merged head, including five documentation conformance tests (13.8 s / 462 MiB peak).
  • Real public CLI/MCP comparisons on both APKs —passed; selected ASCII identities additionally checked against independently parsed DEX metadata. Full-inventory oracle is producer-relative.
  • git diff --check —passed.

Protocol 2 not rerun on macOS/Windows/JDK25. Actual model usage, complex RE effectiveness and target runtime unmeasured. Both Greptile findings (repeated scans and durable native later-page coverage) fixed; re-review 5/5 on merged head cbecc6217; both threads resolved with root cause, fix and validation. Main's unrelated format failure fixed by #4796 and merged here; all 41 enabled checks passed on merged head cbecc6217, including all five test shards, package, static/docs and platform lanes. Codex review quota exhausted; readiness workflow disabled at repository level; no repository settings changed.

Author readiness

Human owner: @N0zoM1z0

Declarations are entered by the agent at the human owner's explicit direction. Diff and evidence checks reported here were performed by the agent; this does not assert a separately observed human review.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • This PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4791 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `perf/android-class-filter-4776` --- ### 📝 Commits (3) - [`4249918`](https://github.com/morluto/rea/commit/4249918555bd0c0ec69de36b346c3e03159ea5a7) perf(android): filter class pages before bridge serialization - [`163393c`](https://github.com/morluto/rea/commit/163393c11efcd1a4b92e2eb3ed0580bb6e0b8dcc) perf(android): continue class pages from examined inventory positions - [`cbecc62`](https://github.com/morluto/rea/commit/cbecc6217e816b0a43521252a0beb18773579a72) chore: merge main into Android class filtering ### 📊 Changes **16 files changed** (+361 additions, -73 deletions) <details> <summary>View changed files</summary> 📝 `bridge/android/ReaJadxBridge.java` (+28 -12) 📝 `docs/android-analysis.md` (+8 -4) 📝 `scripts/verify/android/analysis.mjs` (+2 -0) ➕ `scripts/verify/android/class-search.mjs` (+45 -0) 📝 `scripts/verify/android/metadata.mjs` (+7 -0) 📝 `src/android/JadxAnalysis.ts` (+22 -23) 📝 `src/android/JadxProtocol.ts` (+3 -1) 📝 `src/android/JadxRelease.ts` (+1 -1) 📝 `src/application/android/AndroidSearchEvidenceSummary.ts` (+6 -8) 📝 `src/contracts/android/androidToolContracts.ts` (+1 -1) 📝 `tests/boundary/android/JadxAnalysis.test.ts` (+142 -0) 📝 `tests/boundary/process/androidAnalysisMcp.test.ts` (+4 -3) 📝 `tests/boundary/process/androidSearchEvidenceBudget.test.ts` (+25 -7) 📝 `tests/boundary/process/jadxIntegration.test.ts` (+8 -6) 📝 `tests/conformance/android/ReaJadxMetadataRegression.java` (+39 -0) 📝 `tests/fixtures/android/jadx-mcp.mjs` (+20 -7) </details> ### 📄 Description ## Summary Fixes #4776. Select Android class names inside the JADX bridge before serialization. Previously a focused NewPipe query returned two matches but transferred all 7,096 names and emitted ~383 KB of complete CLI Evidence. ## Change and scope The existing session-owned inventory supplies matching rows and a next inventory position. Later pages resume there, so complete searches scan once without another index or result cache. The adapter validates contiguous examined ranges, global counts, scope, page identity and selection before declaring completeness. Original query, ordering, duplicate counts, APK/engine identity and complete producer replies survive; empty query still inventories all top-level names. Bridge arguments are parsed once. Semantic owner: native bridge; CLI/MCP share the provider. Existing snapshot freshness, JVM bounds and cleanup remain authoritative. Private bridge protocol 2 uses the unmodified JADX headless 0.7.1 JAR. Public input/output shapes remain unchanged; the description clarifies top-level scope. Complete raw Evidence now contains selected pages. No generated outputs committed. Existing static APK scope: reads selected data, launches an owned JVM and writes private temporary files; no APK execution, device interaction or original-byte mutation. Additional maintainer scope decision: not applicable. ## Executed performance evidence Pinned comparison: `e5ee3ac65` versus cursor fix `163393c11`; merged main `bd3210eb2` into head `cbecc6217` afterward, without changing the measured JADX source. Linux x86-64, Temurin 21, official NewPipe 0.29.1 / ApiDemos 6.0.18. Serial runs on one CPU, 768 MiB JVM heap, 4 GiB family cap, fresh JVM/session, OS caches warm/uncontrolled. Normalized matches/order/duplicates/full inventories agree; original APK hashes and cleanup verified, OOM 0. | Workflow | NewPipe before → after | ApiDemos before → after | |---|---|---| | Default complete CLI stdout bytes |383,302 →3,658|134,960 →3,558| | CLI stdout estimated tokens |80,140 →984|29,259 →953| | Seven warm MCP queries (two sessions/revision) |1,015–1,116 →782–785 ms|1,059–1,202 →849–1,048 ms| | Cold CLI wall (two runs/revision) |18.1–18.7 →19.5 s|14.3–15.7 →14.8–15.1 s| | Cold CLI CPU / family peak |17.8–18.3 →19.2 s /988–994 →981–987 MiB|14.0–15.4 →14.5–14.8 s /832 →830–832 MiB| Token estimates use pinned tiktoken 0.14 / cl100k on full stdout; commands add 72–84 tokens. Actual model usage, help discovery, prompts, reasoning and tool framing unmeasured. MCP already summarizes: no material MCP token reduction. Including discovery of all 207 tools, orientation workflows estimate 832,839–832,865→831,921–831,967(NewPipe) and 821,755–821,797→822,093–822,099(ApiDemos); catalog 802,821→802,823 tokens. Raw envelopes count text/structured copies; real client exposure unknown. Whole MCP harness (discovery, orientation, broad/full correctness oracles, cleanup): NewPipe wall 28.9–40.4→31.6 s / CPU 28.5–39.7→31.1–31.2 s / peak 1,514–1,516→1,509–1,518 MiB; ApiDemos wall 25.3–26.8→25.7–27.1 s / CPU 24.9–26.5→25.4–26.8 s / peak 1,440–1,446→1,435–1,442 MiB. Peaks are kernel process-family memory including file cache, not RSS. No stable whole-task CPU/memory gain. NewPipe cold CLI was 5–8% slower in these samples; cause not isolated, and no startup speedup is claimed. Broad-query control: seven warm calls1.613→1.651 s, one session/revision; no general broad speedup established. Post-main public MCP workflows also pass for both APKs with identical normalized digests: NewPipe 30.3 s wall/29.6 s CPU/1,574 MiB peak; ApiDemos 26.4 s/26.1 s/1,358 MiB. Current main's catalog is 802,937 estimated tokens; complete orientation workflow estimates 832,067/822,203. Separate instrumented shared-service diagnostic (one pair, not public CLI timing) shows native initialization 3.58→3.42 s and load 10.70→10.63 s; it does not explain the observed CLI cold difference. ## Validation Merged as `2d84c800bc51dc865fcabdd3e28cda3d2f4413e7`. Verified again in a separate checkout of that actual commit (including intervening main Electron/ELF/README changes): runtime rebuild plus 78 focused tests passed (190.0 s wall/186.1 s CPU/2,813 MiB family peak, 8 GiB cap); real NewPipe production MCP orientation/broad/full-inventory workflow passed (34.4 s/32.1 s/1,698 MiB); real ApiDemos default CLI output passed against the pinned baseline (14.5 s/14.1 s/839 MiB). Native smoke runs kept the original 4 GiB/one-CPU/768 MiB JVM settings. Original APK hashes unchanged, all runs verified owned cleanup and zero OOM events. Both requested co-author trailers are present on the squash commit. PR-head CI: all 41 enabled checks passed; exact-head Greptile 5/5, both review findings fixed/resolved. CLI token savings are offline estimates; no actual model usage, startup speedup or general whole-task CPU/memory benefit claimed. Separate Apktool repeated resource decoding proposal remains #4777. - Focused four Android boundary files — 78 passed; sparse multi-page cursors, duplicates, malformed/non-progressing ranges, empty inventory, retention, lifecycle and failure provenance. Passed again on merged head `cbecc6217` (162.3 s wall / 158.2 s CPU / 2,788 MiB peak). - Full real `node scripts/verify/android/analysis.mjs` —passed on `163393c11`: five CLI/MCP operations/parity, metadata/overloads/initializers/cross-DEX invokes, actual-Java limits 17/1 and nonzero offsets against native inventory, literal/Unicode/NUL/lone-surrogate selectors, cancellation and readiness/failure recovery. 347.4 s wall / 343.8 s CPU / 1,915 MiB peak; 8 GiB cap / 512 MiB heap / one CPU, cleanup verified/OOM 0. - `npm run check` — passed on merged head `cbecc6217`, including cache-miss full typecheck, lint/format/knip/metadata and architecture checks. 222.7 s wall / 218.1 s CPU / 4,153 MiB peak; 8 GiB cap, cleanup verified/OOM 0. Earlier 4 GiB attempt guard-stopped and is excluded. - `npm run docs:check` — passed on merged head, including five documentation conformance tests (13.8 s / 462 MiB peak). - Real public CLI/MCP comparisons on both APKs —passed; selected ASCII identities additionally checked against independently parsed DEX metadata. Full-inventory oracle is producer-relative. - `git diff --check` —passed. Protocol 2 not rerun on macOS/Windows/JDK25. Actual model usage, complex RE effectiveness and target runtime unmeasured. Both Greptile findings (repeated scans and durable native later-page coverage) fixed; re-review 5/5 on merged head `cbecc6217`; both threads resolved with root cause, fix and validation. Main's unrelated format failure fixed by #4796 and merged here; all 41 enabled checks passed on merged head `cbecc6217`, including all five test shards, package, static/docs and platform lanes. Codex review quota exhausted; readiness workflow disabled at repository level; no repository settings changed. ## Author readiness Human owner: @N0zoM1z0 Declarations are entered by the agent at the human owner's explicit direction. Diff and evidence checks reported here were performed by the agent; this does not assert a separately observed human review. - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] This PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:14:16 +00:00
bsakaguchi changed title from [PR #4791] [MERGED] perf(android): filter class pages before bridge serialization to [PR #4791] perf(android): filter class pages before bridge serialization 2026-11-03 13:33:18 +00:00
bsakaguchi changed title from [PR #4791] perf(android): filter class pages before bridge serialization to [PR #4791] [MERGED] perf(android): filter class pages before bridge serialization 2026-11-03 14:35:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6412
No description provided.