Files
battleship/docs/RESOURCE_BUDGET.md
T

3.6 KiB

Resource budget

Measured feasibility baseline

Milestone 004's accepted ESP32-C6 run completed 20 games of 200 updates with two players and eight spectators. Its measured values were 1,000,496 B flash, 38,204 B RAM, 249,616 B minimum free heap, 320 B largest state message, 154 us maximum generation time, and 5,283 us maximum asynchronous delivery-enqueue time. The application partition is 2,097,152 B and LittleFS is 2,031,616 B.

Hard production limits

Resource Limit Basis
Firmware image 1,500,000 B M004 fixed threshold, leaving 597,152 B app-partition reserve
LittleFS image 250,000 B M004 fixed threshold, leaving 1,781,616 B filesystem reserve
Minimum free heap 96,000 B M004 fixed threshold; observed minimum was 249,616 B
Largest role-safe state JSON 768 B Two bounded 80-byte display names plus role-safe game state
HTTP JSON request body 192 B Largest defined command (join) fits within this bound
WebSocket incoming frame 192 B hello is the largest defined incoming frame
HTTP request target/query 128 B /api/state?version=4294967295 is below this bound
State generation 100,000 us M004 fixed threshold; observed maximum was 154 us
State delivery enqueue 100,000 us M004 fixed threshold; observed maximum was 5,283 us
Pending application commands 16 Fixed bounded queue; excess requests return SERVER_BUSY
Sessions 10 Two players and eight spectators
Open HTTP sockets 12 Ten clients plus two polling/transport headroom; LWIP is configured for 16

No handler may allocate a per-client complete JSON state. It serializes one bounded snapshot at a time into the 768-byte transport buffer.

Per-milestone budget gates

Milestone Firmware ceiling LittleFS ceiling Heap floor Required check
006 architecture 1,080,000 B 250,000 B 220,000 B clean build and host tests
007 game core 1,180,000 B 250,000 B 190,000 B fleet and rules tests
008 sessions/API 1,300,000 B 250,000 B 150,000 B role filtering and malformed input
009 transport/UI 1,420,000 B 250,000 B 115,000 B two players/eight spectators
MVP completion 1,500,000 B 250,000 B 96,000 B repeated on-board game test

Each gate is a maximum permitted consumption or minimum required remaining heap. A missed gate blocks the next milestone pending a documented decision.

Milestone 024 browser-audio asset measurement

The bounded Web Audio foundation adds web_audio.js: 7,863 B raw and 2,072 B gzip. The current six compressed web assets total 24,947 B, well below the 250,000 B LittleFS ceiling. The browser performs synthesis locally, so this change adds no ESP32 RAM allocation, API payload, or firmware-code cost.