Skip to content

perf: optimize Protocol V2 BLE transfer throughput and metrics - #902

Draft
wabicai wants to merge 2 commits into
onekeyfrom
perf/pro2-ble-transfer
Draft

perf: optimize Protocol V2 BLE transfer throughput and metrics#902
wabicai wants to merge 2 commits into
onekeyfrom
perf/pro2-ble-transfer

Conversation

@wabicai

@wabicai wabicai commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Prefer Protocol V2 BLE writes without response across React Native, Electron, and the CLI while retaining explicit with-response fallback and caller overrides.
  • Size Protocol V2 BLE packets from negotiated platform capacity, keep the generic filesystem limit conservative, and use the verified 1960-byte budget only for fixed firmware and wallpaper package paths.
  • Improve lossless Pro2 host-asset LZ4 block compression with a firmware-safe fallback for incompressible input.
  • Report firmware transfer progress as whole-batch confirmed bytes, average bytes per second, and elapsed time across resources, components, verification, recovery, and retry delays.
  • Preserve V2-first protocol acquisition for V2-only methods and document the tested BLE throughput and compatibility boundaries.

Measured results

  • Wallpaper baseline (64 B transport packets / 1800 B file chunks): 8.81 KiB/s.
  • Optimized wallpaper (244 B negotiated packets / 1960 B fixed-path chunks): 16.72 KiB/s average.
  • Pro2 4B8F bootloader update (2,440,562 B): 145.62 s transfer, 16.37 KiB/s average, 13.65 s install, 211.96 s CLI end-to-end, 0 retries.
  • The 15 ms firmware connection interval measured 20.3 KiB/s versus 14.22 KiB/s at 30 ms. Connection-parameter changes remain outside this SDK-only PR.

Test coverage

  • 10 focused Jest suites passed: 528 passed, 4 skipped, 532 total.
  • yarn workspace @onekeyfe/hd-core build passed.
  • Targeted ESLint for FirmwareUpdateV4.ts passed.
  • Coverage includes packet capacity/fallback behavior, write mode selection, V2 frame boundaries, file-write retry/progress, V2-only connection acquisition, host-package integrity and incompressible fallback, and whole-batch firmware metrics.

Pre-landing review

  • No P0/P1 findings after tracing the file-transfer, retry, MTU, compression, and progress-event paths.
  • git diff --check passed.
  • The full @onekeyfe/hd-core package lint remains unusable because the existing package TypeScript configuration excludes test/dist inputs and reports unrelated baseline issues; targeted lint and the build are green.

Documentation

  • Updated docs/testing/pro2-ble-performance.md with the CLI commands, device/firmware versions, before/after results, bottleneck analysis, safe limits, platform behavior, and the firmware metric contract.

Companion PR

Test plan

  • Verify wallpaper upload over BLE with negotiated packet capacity and a 1960-byte fixed-path chunk.
  • Verify a locally built firmware update in bootloader mode on Pro2 4B8F.
  • Verify transfer metrics remain cumulative across a Protocol V2 firmware batch.
  • Verify React Native, Electron, CLI, low-level, transport, and core regression suites.

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