velxio/backend/app
davidmonterocrespo24 4908525692 perf(espidf): drop in ccache for ESP32 compiles (~10× warm speedup)
Cold first compile per container is unchanged (cache empty). Subsequent
compiles drop from ~5-7 minutes to ~30-60 seconds because every ESP-IDF
base object (FreeRTOS, lwIP, esp_wifi, libsodium, soc, hal, …) hits the
cache. The user's BMP280 example, which hangs on cold compile, completes
near-instantly on the second attempt.

Why a transparent cache is safe: ccache hashes the preprocessed source +
flags + compiler. A cache hit only happens when the input is byte-for-byte
identical to a prior compile. Different sketches with different libraries
still get correct cache misses; there is no path where one project's
output contaminates another.

Changes
- Dockerfile.standalone: install ccache, set CCACHE_DIR=/var/cache/ccache,
  IDF_CCACHE_ENABLE=1, configure 2 GB cap with compression. Compression
  (level 6) cuts cache disk usage by ~40% with negligible CPU overhead.
- docker-compose.yml: named volume `ccache:/var/cache/ccache` so the
  cache survives `docker compose up -d --build` (without it, every image
  rebuild discards the cache).
- backend/app/services/espidf_compiler.py: pass `-DCCACHE_ENABLE=1` to
  cmake when IDF_CCACHE_ENABLE is truthy. ESP-IDF's project.cmake
  (`set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)` on line 374)
  is what actually wires ccache in; without the cmake -D flag the env
  var alone has no effect because we don't go through idf.py.

Escape hatch: set IDF_CCACHE_ENABLE=0 in compose env to disable without
rebuilding the image.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 05:44:29 +02:00
..
api Merge pull request #137 from davidmonterocrespo24/esp32-cam 2026-05-02 22:40:06 -03:00
core feat: add admin management features and user role handling 2026-03-06 23:46:36 -03:00
database feat: implement user authentication and project management features 2026-03-06 10:14:50 -03:00
mcp feat: integrate MCP (Model Context Protocol) for agent compatibility 2026-03-11 15:29:55 +00:00
models feat(backend): subscription state columns on users table 2026-05-05 10:21:37 -03:00
schemas feat(backend): subscription state columns on users table 2026-05-05 10:21:37 -03:00
services perf(espidf): drop in ccache for ESP32 compiles (~10× warm speedup) 2026-05-09 05:44:29 +02:00
utils feat(metrics): add usage analytics dashboard with country tracking 2026-04-25 19:47:40 -03:00
__init__.py feat: Implement Arduino Simulator with component management and simulation features 2026-03-03 00:20:49 -03:00
main.py feat(backend): subscription state columns on users table 2026-05-05 10:21:37 -03:00