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
{{ message }}
Repository navigation
perf(stl): ThreadLocalReal stores an inline default T, doubling SingletonThreadLocal RAM on ESP32/host #5304
On multithreaded targets (ESP32, host) ThreadLocalReal<T> (src/fl/stl/thread_local.h:~141) stores an inline T mDefaultValue in addition to the per-thread heap copy. For SingletonThreadLocal<T> with a large T, this roughly doubles RAM: measured with xtensa-esp32 gcc 8.4, a 989 B T costs 996 B static storage plus ~990 B heap per thread on first access (never freed for singletons), and each access goes through a 198 B accessor (vs 39 B for Singleton).
Proposed solution
Don't store a full inline default T when the default is just value-initialization: e.g. store the default only when a non-default value was supplied, or construct per-thread copies with T() directly.
Keep API and semantics (per-thread copy initialized from the default) unchanged; unit test that per-thread values start at the provided default and are independent.
Host regression check that sizeof(ThreadLocal<Big>) with no explicit default is not O(sizeof(Big)).
Activity
fix(stl): ThreadLocalReal keeps its default on the heap only when one…