Disabling SMT for better single-threaded performance
- Peter
- Jul 5, 2024
- 2 min read
Today's post is based on the following hypothesis:
SMT (Simultaneous Multithreading) results in slightly slower single-threaded performance by burdening CPU cores with activities unrelated to the primary thread. Disabling SMT will improve single-threaded performance by dedicating 100% of the CPU core and related caches to a single task.
To test this hypothesis I ran the benchmark suite on my Linux PC, once with SMT ON (the default) and then a second time with SMT OFF. The results are as follows:
Mypy
Mypy is the benchmark that I had most hoped to improve as it is currently the benchmark where the Linux PC is furthest behind the Mac (51% slower at last comparison). Unfortunately disabling SMT has resulted in just a tiny 1% improvement which is within the margin of error, so it seems SMT actually doesn't degrade single-threaded throughput.

Pytest (Empty Test / Single Test)
The pytest benchmarks are similar to mypy in that they are constrained by single-threaded performance and I had hoped to see an improvement in these benchmarks by disabling SMT. But here the improvements are even more tiny - just 0.3% improvement for running the empty test and 0.5% improvement on the single test average.


Git Log / Git Status / Ripgrep
And now we have to address the severe downside to disabling SMT - that many well-designed programs are able to run faster by spreading work across additional threads that the CPUs can execute in small bursts when their main thread is stalled, and disabling SMT will slow down those programs by cutting access to that free CPU execution time and forcing them to wait for dedicated CPU cores.
The "git log" command used for my benchmarking doesn't appear to make use of the extra threads so isn't really affected (only 0.1% slower with SMT disabled), but "git status" is a full 10% slower when SMT is disabled, and Ripgrep is a massive 48% slower with SMT disabled.



Summary
My original hypothesis is disproven. Disabling SMT doesn't improve single-threaded throughput by a detectable amount.
In addition, even though expected that some benchmarks would be negatively effected by disabling SMT I didn't realise it would be as high as a 48%. That's almost an extra 4 cores' worth of processing being completed.



Comments