logoalt Hacker News

pjmlp • today at 11:07 AM • 4 replies • view on HN

Based on my experience, hyper threading was anyway a workaround until multicore became widely available, not sure how much it is still worthwhile, given the impact in shared units across the CPU.

Usually having hyperthreads killing each other's cache entries, is much worse that splitting the work across multiple real cores, with a few synchronisation points.


Replies

gsliepen • today at 11:48 AM

Hyper-threading is a way to make better use of the execution engines of a CPU core. Some instructions stall (for example, because they need to wait for memory), so you want to run something else in the mean time. Instruction reordering and speculative execution only goes so far. If you have a completely separate thread available that can do some useful work, then you improve the overal efficiency.

Note that GPUs basically are hyper-threaded CPUs that not have just 2 or 4 threads per core, but thousands. This approach avoids needing all the complicated out-of-order circuitry, but it only works if you really have thousands of threads, which for a GPU is actually the case.

➕ show 1 reply
ls65536 • today at 12:55 PM

It can often still be worthwhile to keep SMT enabled (if available), and very often it is for many general use cases, but it definitely depends on the workload.

Modern cores have become exceptionally good at extracting instruction-level parallelism from a single thread, so SMT becomes relatively less useful all else being equal. At the same time, modern cores also have much wider and more numerous internal resources where a single thread will be more likely to leave more of these resources idle (which could be useful to another simultaneously executing thread).

It seems that if you have two threads that tend to each saturate or bottleneck on the same internal CPU resources (execution resources, various buffers, caches, etc.), then SMT is more likely to reduce overall performance compared to just running a single thread at a time sequentially. But you need to measure to be sure.

As a fun anecdote, one of the best relative improvements I've seen in leaving SMT enabled (vs. disabled) was on one of the earliest (in-order!) Intel Atom CPUs. I suppose getting good ILP out of a single thread was simply not possible there, so even with the tiny execution resources available in that CPU there was still plenty to allow another thread to benefit from substantially.

swiftcoder • today at 11:24 AM

Hyperthreading was also a workaround for software that did all its networking by leaving hundreds (or even thousands) of OS threads blocked on IO.

As epoll/kqueue/iocp/io_uring et al have become more widely adopted, and we offload a lot more of this IO multiplexing into userspace, the value proposition gets hazier.

➕ show 1 reply
whizzter • today at 12:51 PM

Doesn't HT help mask cache latencies if your code is very cache-unfriendly? Ie there is computing that can move forward whilst the memory system is waiting?