perf(phase-1/m2.5): export memory measured on synthesized worst-case libraries

Phase 1 M2 task 5 (tools/DESKTOP_PHASE_PLAN.md §4): measure & record,
no redesign. New :core:data-jvm:backupMemory probe (2g heap) samples
heap-used at 1 ms during BackupBridge.exportPlain — the phone's own
export path — across four fresh libraries:

  24 MB data (3 att)  → peak 230 MB   |  2 MB text x2000 notes → 140 MB
  80 MB data (10 att) → peak 777 MB   | 320 MB data (40 att)  → OOM at -Xmx2g

Attachments drive memory (~9–10x allocation pressure: store load →
base64 String → UTF-8 bytes → JsonElement tree); note count alone is
trivial. The plan's 250 MB gate trips at ~25–30 MB of attachments, and
the phone (no largeHeap) shares the ceiling — a pre-existing Android
limitation, unchanged by the bridge extraction. The real library
exports at 366 KB ≈ 1000x headroom. Bonus: a ~1.6 GB library dies in
objectbox-java's DbFullException before the bridge ever sees it.

Verdict: record, don't redesign. Streaming formatVersion=2 stays parked
for Phase 2, required only if attachment libraries approach ~25 MB.
This commit is contained in:
Incido Developer committed 2026-10-05 19:48:02 +13:00
1 parent 52ccceb732
commit 9cb7fdbf58
3 files changed
+195

No files matched your search

+15
View File
@@ -103,4 +103,19 @@ tasks.register<JavaExec>("backupSmoke") {
description = "Round-trips a real Android backup export through BackupBridge on the JVM."
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.incido.data.jvm.BackupRoundTripKt")
}
/**
* `./gradlew :core:data-jvm:backupMemory` — synthesizes worst-case
* libraries and samples heap peak during BackupBridge.exportPlain
* (Phase 1, M2 task 5: measure & record, no redesign). Needs a bigger
* heap than the other probes on purpose — the "watch tier" is ~320 MB of
* attachments and the bridge holds the whole JSON in memory by design.
*/
tasks.register<JavaExec>("backupMemory") {
group = "verification"
description = "Measures export heap peaks on synthesized worst-case libraries (M2 t5)."
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.incido.data.jvm.BackupMemoryProbeKt")
maxHeapSize = "2g"
}