Skip to content

perf(display): reclaim unused LVGL draw buffer - #122

Merged
zjwhitehead merged 1 commit into
masterfrom
perf/reclaim-lvgl-buffer
Aug 24, 2026
Merged

perf(display): reclaim unused LVGL draw buffer#122
zjwhitehead merged 1 commit into
masterfrom
perf/reclaim-lvgl-buffer

Conversation

@zjwhitehead

@zjwhitehead zjwhitehead commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • register one half-screen LVGL draw buffer while the display flush remains synchronous
  • remove the unused second 20,480-byte static buffer
  • document when double buffering should return

Why

The current Adafruit SPI flush writes the complete dirty rectangle before returning and before calling lv_display_flush_ready(). LVGL therefore cannot render into the second buffer concurrently, so that buffer consumes internal SRAM without providing pipeline throughput.

This reduces target static RAM usage by 20,480 bytes, from 140,920 bytes (43.0%) to 120,440 bytes (36.8%). Double buffering should be restored when the display transport moves to asynchronous DMA.

@zjwhitehead zjwhitehead left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Single-buffer is correct while the SPI flush stays synchronous. Confirm Adafruit endWrite() waits for DMA, then this is a clean SRAM win.

(Could not formally approve: GitHub blocks self-approval on your own PR.)

@zjwhitehead

Copy link
Copy Markdown
Member Author

Hardware-in-loop validation (M5Stack StampS3 over USB, no ESC/BMS connected): linked static RAM fell from 140,992 to 120,512 bytes (exactly 20,480 bytes). At runtime, steady free/internal heap rose from 100,892 to 121,216 bytes (+20,324 usable), and the largest contiguous internal allocation rose from 90,112 to 110,592 bytes (exactly +20,480). Under the same safe 10 s dry-cruise state transition, the display handled 52 flushes across sampled windows with 0 skipped flushes; representative flush averages were 782–1,213 us and maxima 1,736–3,146 us, in the baseline range. Heap returned to and remained steady at 121,216 bytes after redraw activity. This confirms the second buffer is unused by the synchronous transport and can be reclaimed without observed display regression.

@zjwhitehead
zjwhitehead merged commit d0c4bf7 into master Aug 24, 2026
10 checks passed
@zjwhitehead
zjwhitehead deleted the perf/reclaim-lvgl-buffer branch August 24, 2026 01:37
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