You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These scratch users run only on large boards and could be moved onto fl::scratch for consistency:
the SingletonThreadLocal<fl::vector> grow-only scratch in src/fl/gfx/blur.cpp.hpp, src/fl/channels/channel.cpp.hpp and src/fl/audio/fft/fft_impl.cpp.hpp
StbvTempBuffer in src/third_party/stb/stb_vorbis.cpp.hpp
It's low priority. Evaluate whether it saves RAM or code on ESP32; skip any where it doesn't.
Evaluation (automated worker): no change. Moving these four users onto fl::scratch saves no RAM or code on ESP32, and it would make things worse.
ESP32 builds always use the inline path. ESP32 sets FASTLED_MULTITHREADED=1 (src/fl/stl/thread_config.h), and fl/stl/scratch.h refuses (#error) a non-zero FL_SCRATCH_STACK_BYTES on multithreaded builds unless FL_SCRATCH_ALLOW_MULTITHREADED=1 is set. So on ESP32, fl::scratch<T> is just a local T on the task stack. These buffers were put in SingletonThreadLocal to keep them off the 4-8 KB FreeRTOS task stacks (see the comment on FftScratch), so switching them would bring back the stack-overflow risk.
The types don't fit.fl::scratch<T> needs a fixed-size, trivially destructible T. All four users are runtime-sized, grow-only heap buffers:
blur pad buffer: sized from the image width and radius
channel reorder buffer: one CRGB per LED
FftScratch: eight fl::vectors sized by FFT size and band count
StbvTempBuffer: a bump allocator of 64 KB or more that grows and needs stable pointers within a save/restore scope
None of them can be expressed as a fixed T. Even when an arena is on, its fixed, never-growing capacity can't hold them.
They're also thread-safe today. Each thread has its own SingletonThreadLocal. The fl::scratch arena is one shared, unlocked, not-thread-safe area.
fl::scratch is meant for fixed multi-hundred-byte working sets on single-threaded small-stack targets (for example ESP8266 and drawPolygon). The current SingletonThreadLocal<fl::vector> approach is the right fit for these users. Suggest closing as won't-do. (Since nothing changes, this does not conflict with #5163.)
Closing as won't-do, following the evaluation above. On ESP32, fl::scratch<T> is a local on the task stack (multithreaded builds require FL_SCRATCH_STACK_BYTES=0). All four users are runtime-sized, grow-only buffers, which a fixed T can't hold. The current SingletonThreadLocal<fl::vector> keeps them per-thread and off the 4–8 KB FreeRTOS stacks. Moving them would save no RAM or code and would bring back the stack-overflow risk.
Activity
zackees commentedon Nov 21, 2026
Evaluation (automated worker): no change. Moving these four users onto
fl::scratchsaves no RAM or code on ESP32, and it would make things worse.ESP32 builds always use the inline path. ESP32 sets
FASTLED_MULTITHREADED=1(src/fl/stl/thread_config.h), andfl/stl/scratch.hrefuses (#error) a non-zeroFL_SCRATCH_STACK_BYTESon multithreaded builds unlessFL_SCRATCH_ALLOW_MULTITHREADED=1is set. So on ESP32,fl::scratch<T>is just a localTon the task stack. These buffers were put inSingletonThreadLocalto keep them off the 4-8 KB FreeRTOS task stacks (see the comment onFftScratch), so switching them would bring back the stack-overflow risk.The types don't fit.
fl::scratch<T>needs a fixed-size, trivially destructibleT. All four users are runtime-sized, grow-only heap buffers:CRGBper LEDFftScratch: eightfl::vectors sized by FFT size and band countStbvTempBuffer: a bump allocator of 64 KB or more that grows and needs stable pointers within a save/restore scopeNone of them can be expressed as a fixed
T. Even when an arena is on, its fixed, never-growing capacity can't hold them.They're also thread-safe today. Each thread has its own
SingletonThreadLocal. Thefl::scratcharena is one shared, unlocked, not-thread-safe area.fl::scratchis meant for fixed multi-hundred-byte working sets on single-threaded small-stack targets (for example ESP8266 and drawPolygon). The currentSingletonThreadLocal<fl::vector>approach is the right fit for these users. Suggest closing as won't-do. (Since nothing changes, this does not conflict with #5163.)zackees commentedon Nov 21, 2026
Closing as won't-do, following the evaluation above. On ESP32,
fl::scratch<T>is a local on the task stack (multithreaded builds requireFL_SCRATCH_STACK_BYTES=0). All four users are runtime-sized, grow-only buffers, which a fixedTcan't hold. The currentSingletonThreadLocal<fl::vector>keeps them per-thread and off the 4–8 KB FreeRTOS stacks. Moving them would save no RAM or code and would bring back the stack-overflow risk.