C++ Thread-Local Storage Performance Pitfalls: 0 + 0 > 0?

2025-02-17
C++ Thread-Local Storage Performance Pitfalls: 0 + 0 > 0?

This article delves into the performance implications of using thread_local variables in C++. By analyzing assembly code, the author reveals significant performance discrepancies in different scenarios, particularly with thread_local variables having constructors and those used in shared libraries. Even simple accesses can suffer dramatic slowdowns due to constructor calls, dynamic loading of shared libraries, and other factors. The article concludes with performance optimization guidelines and discusses future improvements, aiming to help developers avoid thread_local performance traps.

Read more
Development

An Engineer's Journey with Forth: From Fascination to Abandonment

2024-12-28

This blog post recounts an engineer's experience learning and using the Forth programming language. Initially captivated by Forth's brevity and extensibility, the author delved into the source code of pForth, marveling at its compile-time self-modifying capabilities. However, in real-world projects, the author found Forth more suitable for number crunching, struggling with tasks like text processing. While designing a custom hardware embedded system, the author leveraged Forth to design the system's CPU instruction set, but ultimately found C more efficient and abandoned Forth. The author concludes that Forth is ideal for minimalist engineers seeking extreme efficiency, while he himself prefers a more pragmatic approach, opting for more widely used languages.

Read more
Development