This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com
Last weekend, we did a live session on the architecture of the hyper-threading (simultaneous multithreading) implementation in Intel’s x86 processors. We went into all the nitty gritty of the microarchitecture and dissected how instruction execution works at each stage of the execution pipeline and how hyper-threading affects that flow. Enjoy the recording!
Accessing the Recording
The session was free for the paid supporters and the recording is also available to them. To access it you can upgrade your subscription.
However, if you are not based in India, then your payment to Substack will fail because they are not following Indian regulations (see my post on how Substack has failed Indian writers). So you have three options:
* You can become a member at buymeacoffee and I will upgrade you to a paid supporter on Substack so that you can access this recording and everything else.
* You can sponsor me on GitHub and I will upgrade you to a paid subscription here and you can access this recording and everything else.
* You can simply purchase access to this video using the following link:
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
SPEAKER_00Okay.
SPEAKER_00Okay, so we are going to talk about hyperthreading. Essentially, the goal is to talk about how hyperthreading actually works at the lowest level of the hardware. So I think many people are aware what hyperthreading is, but how exactly it works and what are the trade-offs of using it or not using it. Those are the kind of things that many of us are not really aware of.
SPEAKER_00So that is the goal to understand. So this talk, even though, so we will be talking about the hardware only at the conceptual level. So we're not really going to go at the Implementation level, as in we are not really going to discuss the intricate implementation details, but just how hyperthreading works and what are the various components involved at
SPEAKER_00the microarchitecture level and how they are shared and used between the threads. That is the goal. So let's first talk about what hyperthreading is. I think many of us are aware of it, but for the sake of completeness, So hyperthreading is essentially, it's a technology or a hardware feature that allows us to execute two threads
SPEAKER_00simultaneously on the same processor code. So in the alternative, or the traditional multi-threading is that when you're running multiple threads, a single processor core will context switch between those threads. So at any point of time, that processor core will only be executing instructions for one thread. But in the case of hyper-threading, the processor core can actually be executing thread instruction for two threads at
SPEAKER_00the same time. Um, so that is what hyper-threading is. Uh, many of us are really familiar with, with that level of definition, but we are going to go much deeper in the next one up. So, um, what is the motivation behind introducing this hyper-threading technology? Um, so many, again, uh, at, at
SPEAKER_00If you just want to talk about at a very high level, the core goal when this feature was introduced into the processors was to increase the utilization of the processor resources. So when the processor is executing only a single thread or a single program at a time, there are limitations because of which it will not be able to utilize all the execution resources that are available on the core. And when,
SPEAKER_00if the processor can simultaneously execute multiple threads, then there is a possibility then that it will be better utilized. It will be able to better utilize all the, uh, available processing power that is there on the hardware chip. So that is a surface level, uh, motivation behind the introduction, introduction of this feature. So this was introduced like, uh, The idea came up probably in the 90s. There were papers which came out, which talked about the idea of simultaneous multithreading.
SPEAKER_00That is the technical term. And eventually, I think in 2000s, somebody in the early 2000s, Intel implemented this in their processors and they called it hyperthreading. Now, we are going to go deeper than uh this surface level idea of utilize better utilization of processor resources so i want to spend some time uh explaining uh some of how we evolved to this point
SPEAKER_00where we had to implement something like uh hyper threading so the real motivation behind hyper threading so processor the process The technology behind, uh, processes is pretty old. So, and, uh, we are all aware with Moore's law. So every one and a half years, the number of transistors on the processor chip, uh, was doubling for a long while.
SPEAKER_00So this can, as you can see in this figure, the trend continued for a long time. Although in the last decade, we have it a wall on how much we can put on a single processor chip, but for many decades, this trend continued and we were able to double the number of transistors on the CPU chip. Now, this meant that the architects, the hardware architects, they had to figure out ways to utilize all that extra transistor capacity which was available.
SPEAKER_00So the most obvious thing to do was to increase the processing power of the processor, so increase the speed. So now there were various ways to do this. So you could increase the execution resources on the processor. So execution resources are the actual processing So like your arithmetic and logical units, the ALU, you can increase the registers,
SPEAKER_00the number of registers available on the CPU. So those are the execution resources where you could increase those. But that comes with a trade off. So adding those resources requires bigger chips. So that is one. drawback there. And the other thing was, even if you could add a lot of execution resources, you should also be able to utilize them.
SPEAKER_00So can you actually execute all, utilize all those LU units and additional registers? The other thing the architects could do was to increase the clock speed. And we have seen that over the many decades, the processes clock speed has increased significantly. So increased clock speed means that the process could execute more cycles and more instructions.
SPEAKER_00But even then, there is a limit to which you could increase the clock speed because ultimately it causes more power utilization. It increases the sheet which is generated as programs execute on the processor. So there is a limit that you could go to. The next thing they could do was to increase the instruction throughput. So how many instructions per cycle the processor could execute?
SPEAKER_00So that is the main area where a lot of innovation happened over all this period of time. So this is where the idea of hyperthreading also came into. So we'll go deeper into what's behind increasing the instruction throughput. So there are various features which have been added into the processors to increase how many instructions they could execute per cycle. So these are essentially, this is also called instruction level parallelism.
SPEAKER_00So the ability of the processor to execute several instructions in parallel. So one of the most fundamental techniques is pipelining the instructions. So Normally, if you have to execute one instruction from the beginning to the end, and then you start executing another instruction. So one instruction can take one or more cycles. And that means the processor cannot be doing anything else while that single instruction was executing. So that severely limits
SPEAKER_00Utilization of all the resources, like there are so many registers, which are available on the processor, but the CPU is only executing one instruction. So all the registers are being unused. Similarly, there are so multiple arithmetic units, which are available to do multiple integer and floating point. Math, but the processor is only doing one thing. So they came up with the idea of pipelining the instructions. So you break down the execution of the instruction into multiple stages.
This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com In the last video, we learned about copy-on-write (CoW) and understood its mechanics by digging inside the mmap pathway in the...
This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com In the last video, we discussed demand paging. Now, let’s move towards an even more interesting topic: copy-on-write (CoW). Just...
This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com In the previous video in our virtual memory series, we discussed demand paging. But that was mostly theoretical, explaining how...
This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com Welcome back to the video series on virtual memory based on my article on the same topic. It is also available in ebook format on...
This is a free preview of a paid episode. To hear more, visit blog.codingconfessions.com This is a short aside in our virtual memory series. We have talked extensively about the size of a virtual address and the virtual...