https://speakerdeck.com/alblue/understanding-cpu-microarchitecture-for-performance-jchampionsconf ```cardlink url: https://speakerdeck.com/alblue/understanding-cpu-microarchitecture-for-performance-jchampionsconf title: "Understanding CPU Microarchitecture for Performance (JChampionsConf)" description: "Microprocessors have evolved over decades to eke out performance from existing code. But the microarchitecture of the CPU leaks into the assumptions of a flat memory model, with the result that equivalent code can run significantly faster by working with, rather than fighting against, the microarchitecture of the CPU.This talk, given for the JChampionsConf in 2022, presents the microarchitecture of modern CPUs, showing how misaligned data can cause cache line false sharing, how branch prediction works and when it fails, how to read CPU specific performance monitoring counters and use that in conjunction with tools like perf and toplev to discover where bottlenecks in CPU heavy code live. We’ll use these facts to revisit performance advice on general code patterns and the things to look out for in executing systems. The talk will be language agnostic, although it will be based on the Linux/x86_64 architecture.The presentation was recorded at the JChampionsConf meeting in January 2022, and a recording is available here: https://youtu.be/Pa_l3aHCoGc" host: speakerdeck.com favicon: https://d1eu30co0ohy4w.cloudfront.net/assets/favicon-bdd5839d46040a50edf189174e6f7aacc8abb3aaecd56a4711cf00d820883f47.png image: https://files.speakerdeck.com/presentations/46b689c6514847229d5c29776c4701dc/slide_0.jpg?20168742 ``` [Alex Blewitt - Understanding CPU microarchitecture - YouTube](https://www.youtube.com/watch?v=Pa_l3aHCoGc) > マイクロプロセッサは、既存のコードから性能を引き出すために数十年にわたり進化してきました。しかし、CPUのマイクロアーキテクチャは、フラットメモリモデルの前提に漏れ、その結果、同等のコードは、CPUのマイクロアーキテクチャと戦うのではなく、協力することで大幅に高速に実行することができます。 > この講演は、2022年のJChampionsConfのために行われたもので、最新のCPUのマイクロアーキテクチャを紹介し、不整列データがキャッシュラインの偽共有を引き起こすこと、分岐予測の仕組みと失敗例、CPU固有の性能監視カウンターの読み方、それを[[perf]]やtoplevなどのツールと併用してCPU負荷の高いコードのボトルネックを発見する方法などを説明します。これらの事実をもとに、一般的なコードパターンや実行中のシステムで気をつけるべき点など、パフォーマンスに関するアドバイスを再確認します。講演は、Linux/x86_64アーキテクチャをベースとしますが、言語にとらわれません。