Hasty Briefsbeta

Bilingual

Efficient C++ Programming for Modern C++ CPUs, Chapter 4/part 2

6 hours ago
  • #CPU Performance
  • #C++ Optimization
  • #Hardware Costs
  • Multiplication and division have higher latencies compared to other operations, with division being particularly expensive.
  • RTTI, especially dynamic_cast, can be up to 5 times more costly than a simple virtual function call.
  • C++ exceptions are efficient for rare errors but costly when triggered, with exceptions costing thousands of cycles.
  • Atomic operations like CAS involve significant latency and side effects, affecting performance in multi-core systems.
  • Function calls cost around 15-30 cycles, with indirect and virtual calls being more expensive.
  • Inlining functions can optimize code by removing call overhead and enabling compiler optimizations.
  • Thread Local Storage access involves extra indirections, varying by compiler and platform.
  • Thread context switches are expensive, with direct costs around 2,000 cycles and indirect cache invalidation costs potentially reaching millions of cycles.