macOS Sonoma and Core Allocation for Virtual Machines
Apple’s transition to using its own silicon chips in Mac computers has brought about significant changes in the way CPU cores are utilized. The latest M-series chips, such as the M1 Max, feature both Efficiency (E) cores and Performance (P) cores. While E cores are energy-efficient but slower, P cores are faster and handle most of the code execution in apps. The allocation of threads to these cores is determined by macOS based on the Quality of Service (QoS) set by the apps.
However, there are certain scenarios where core allocation works differently. One such case is when running a macOS virtual machine (VM) that is assigned a specific number of virtual cores. This article explores how macOS Sonoma handles core allocation in this atypical situation.
Under macOS lightweight virtualization, VMs are allocated virtual CPU cores that are equivalent to P cores. This means that threads running within the VM cannot be allocated to E cores on the host. Activity Monitor’s CPU History window provides insights into the core allocation and performance of these VMs.
The author conducted tests using a Mac Studio M1 Max running Sonoma 14.0 and a Sonoma 14.0 VM created using Viable. The tests involved running threads with purposeless assembly code performing floating-point arithmetic. The number of virtual cores in the VM was varied, and the QoS for all threads was set to 33.
When running a single thread on three or four virtual cores, the expected changes in P0 cluster frequency and active residency were observed. As the number of threads increased, the number of cores running them reached the limit imposed by the number of virtual cores. The effect on host clusters suggested that VM threads were confined to the P0 cluster.
However, a closer analysis revealed that the threads were distributed across multiple cores within the P0 cluster. Individual core responses showed that the test threads were moved around frequently during each test run. Additionally, when the second P cluster was active, it also handled some of the test load.
This analysis indicates that core allocation for threads running on virtual cores follows similar rules to host threads running at high QoS. There is no specific affinity for clusters or cores, suggesting that virtualization does not introduce a different mode of core allocation.
Overall, macOS Sonoma’s handling of core allocation for virtual machines provides efficient utilization of CPU resources. The ability to distribute threads across multiple cores within a cluster allows for better performance and responsiveness in virtualized environments.
この記事では、macOS Sonomaにおける仮想マシンのコア割り当てについて説明しました。Appleのシリコンチップの導入により、CPUコアの利用方法に大きな変更がもたらされました。最新のMシリーズチップ(例:M1 Max)には、エネルギー効率の高いEコアと高性能なPコアが搭載されています。アプリケーションのコード実行の多くはPコアで行われますが、アプリは直接どのコアで実行されるかを決定することはできません。その権限はmacOSによって持たれ、アプリは自身の重要度を示すQoS(Quality of Service)を設定することで考慮されます。
しかし、コア割り当ては異なる動作をする場合もあります。macOS仮想化環境での動作がその一例です。仮想マシンには仮想CPUコアが割り当てられますが、これらのコアはPコアと同等の性能です。つまり、仮想マシン内で実行されるスレッドはホスト上のEコアに割り当てることはできません。Activity MonitorのCPU履歴ウィンドウを使用して、これらの仮想マシンのコア割り当てとパフォーマンスを観察することができます。
筆者は、Sonoma 14.0を実行するMac Studio M1 Maxと、Viableを使用して作成したSonoma 14.0 VMを使用してテストを行いました。テストでは、無目的のアセンブリコードを使用して浮動小数点演算を行うスレッドを実行しました。仮想マシン内の仮想コアの数を変化させ、すべてのスレッドのQoSを33に設定しました。
3つまたは4つの仮想コアで単一のスレッドを実行すると、P0クラスタの周波数とアクティブリジデンシの変化が予想どおり観察されました。スレッドの数が増えるにつれて、実行されるコアの数も仮想コアの数に制限されました。ホストクラスタに与える影響からは、VMスレッドがP0クラスタに制限されていると思われました。
しかし、詳細な分析により、テストスレッドはP0クラスタ内の複数のコアに分散されていることが明らかになりました。個々のコアの応答を調べると、テストスレッドは各テスト実行中に頻繁に移動されていました。さらに、第2のPクラスタがアクティブな場合、そのクラスタも一部のテスト負荷を処理しているようでした。
この分析からは、仮想コアで実行されるスレッドのコア割り当ては、高いQoSで実行されるホストスレッドと同様のルールに従っていることが示されます。クラスタやコアに特定の親和性はなく、仮想化はコア割り当てにおいて異なるモードを導入するわけではないということです。
全体として、macOS Sonomaにおける仮想マシンのコア割り当ては、CPUリソースの効率的な利用を可能にします。クラスタ内の複数のコアにスレッドを分散させることで、仮想化環境でのパフォーマンスと応答性が向上します。
注意
- この記事はAI(gpt-3.5-turbo)によって自動生成されたものです。
- この記事はHackerNewsに掲載された下記の記事を元に作成されています。
How does macOS manage virtual cores on Apple Silicon? - 自動生成された記事の内容に問題があると思われる場合にはコメント欄にてご連絡ください。