Repository navigation
perf(esp32): non-throwing unique_lock/lock_guard drop libstdc++ locale init (#4798) - #4806
Conversation
…e init (#4798) fl::unique_lock on ESP32 aliased std::unique_lock, whose lock()/unlock() reference std::__throw_system_error. That one reference extracted libstdc++'s system_error.o, which pulls lt5-sstream-inst, ios-inst and the locale objects, whose static constructors (ctype_byname, numpunct/time_get guard variables) are always kept. Move the stub platform's non-throwing lock_guard/unique_lock into platforms/shared/nothrow_lock.h and use it on ESP32 too; std lock tag types stay for source compatibility. esp32dev Blink: flash 295896 -> 294984 (-912), RAM 25812 -> 25492 (-320) esp32dev APA102: flash 291020 -> 290112 (-908), RAM 25276 -> 24956 (-320) esp32s3 Blink: flash 401876 -> 400992 (-884), RAM 77936 -> 77616 (-320) esp32s3 APA102: flash 409656 -> 408768 (-888), RAM 77864 -> 77544 (-320) locale-inst.o no longer in the map. bash test --cpp 319/319, 95/95.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds shared non-throwing ChangesNon-throwing lock wrappers
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No merge-blocking issue is established; the change is ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1❌ Failed checks (1 warning, 1 inconclusive)✅ Passed checks (3 passed)Full details: Linked Issues checkExplanation The change directly addresses
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Part of #4801. Fixes #4798.
Root cause (linker map)
On ESP32,
fl::unique_lockaliasedstd::unique_lock. Its misuse checks reference__throw_system_error, and that single reference extracts the iostream/locale objects. Their static constructors (ctype_byname, plusnumpunct/time_get/moneypunctguard variables) are always kept.Fix
Move the stub platform's existing non-throwing
lock_guard/unique_lockverbatim intoplatforms/shared/nothrow_lock.h, and use it on ESP32 as well. The std lock tag types (std::defer_lock_tetc.) stay, since they are header-only.ConditionVariableESP32only usesmutex(),owns_lock(),lock()andunlock(); no ESP32 code passesfl::unique_locktostd::condition_variable.Evidence (dashboard protocol, fbuild 2.5.38)
libstdc++.a(locale-inst.o)is no longer in the S3 map.bash test --clean --cpp: 319/319 unit, 95/95 examples.bash lintpasses./code-review: no findings.std::unique_lock(mutex_rp.h,mutex_stm32.h) and likely pay the same cost; out of scope for this ESP32 pass.Summary by CodeRabbit