Commit 5555cdb
feat(client): adaptive batch coalescing, configurable via Android UI
Replace the fixed 8ms batch coalesce window with an adaptive scheme:
after each new op arrives, wait another 40ms (step) for more ops.
The timer resets on every arrival, up to 1000ms (max) from the first
op. Both values are configurable via config JSON (coalesce_step_ms,
coalesce_max_ms) and two new sliders in the Android Advanced section.
Why this helps: Apps Script adds ~1.5s overhead per HTTP call. The
previous 8ms window barely caught any concurrent ops — most batches
carried just 1 op. With 40ms/1000ms, batches average 2-3 ops,
reducing total Apps Script calls for the same workload.
Also disables legacy tunnel-node detection (threshold set to 0ms).
The heuristic triggered false positives with longer tunnel-node drain
times, causing the client to back off polling to 30s intervals and
stalling sessions.
Tested on device in Iran:
Before: P75=6.2s, 61% fast (<3s), ~1 op/batch
After: P75=3.0s, 74-85% fast, ~2-3 ops/batch
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7e8e467 commit 5555cdb
5 files changed
Lines changed: 80 additions & 31 deletions
File tree
- android/app/src/main/java/com/therealaleph/mhrv
- ui
- src
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
| 202 | + | |
| 203 | + | |
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| |||
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
| 311 | + | |
| 312 | + | |
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| |||
400 | 406 | | |
401 | 407 | | |
402 | 408 | | |
| 409 | + | |
| 410 | + | |
403 | 411 | | |
404 | 412 | | |
405 | 413 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1246 | 1246 | | |
1247 | 1247 | | |
1248 | 1248 | | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
1249 | 1275 | | |
1250 | 1276 | | |
1251 | 1277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| |||
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
| 380 | + | |
| 381 | + | |
378 | 382 | | |
379 | 383 | | |
380 | 384 | | |
| |||
388 | 392 | | |
389 | 393 | | |
390 | 394 | | |
391 | | - | |
| 395 | + | |
392 | 396 | | |
393 | 397 | | |
394 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
71 | 67 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
80 | 72 | | |
81 | 73 | | |
82 | 74 | | |
| |||
255 | 247 | | |
256 | 248 | | |
257 | 249 | | |
258 | | - | |
| 250 | + | |
259 | 251 | | |
260 | 252 | | |
261 | 253 | | |
| |||
280 | 272 | | |
281 | 273 | | |
282 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
283 | 278 | | |
284 | | - | |
| 279 | + | |
285 | 280 | | |
286 | 281 | | |
287 | 282 | | |
| |||
556 | 551 | | |
557 | 552 | | |
558 | 553 | | |
559 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
560 | 557 | | |
561 | 558 | | |
562 | 559 | | |
| |||
581 | 578 | | |
582 | 579 | | |
583 | 580 | | |
584 | | - | |
| 581 | + | |
| 582 | + | |
585 | 583 | | |
586 | 584 | | |
587 | 585 | | |
588 | 586 | | |
| 587 | + | |
| 588 | + | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
| 592 | + | |
592 | 593 | | |
593 | 594 | | |
594 | | - | |
595 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
596 | 601 | | |
597 | | - | |
| 602 | + | |
598 | 603 | | |
599 | 604 | | |
600 | 605 | | |
| |||
787 | 792 | | |
788 | 793 | | |
789 | 794 | | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
795 | 798 | | |
796 | 799 | | |
797 | 800 | | |
| |||
0 commit comments