The Case of Unsustainable CPU Affinity
This transcript was made by AI. The open source speech recognition model Whisper (large-v3-turbo) transcribed the recording with faster-whisper. Names and technical terms were checked against the paper, but it can still contain mistakes. The recording is the reference.
0:00 So, hi, everyone. It's a pleasure to be here as a first speaker today. Hopefully, you have got some coffee and not been too sleepy at this early point. Yeah, happy to present our recent studies on unsustainable CPU affinity, which is a joint work by U-Toronto and UW. Yeah. So, decarbonization has become a big thing for many institutions, especially for recent operators. And to achieve non-carbon emissions, we need to reduce the operational emissions, and we need to amortize embodied emissions. And ideally and eventually, we should do both. Well, in this paper, we mainly focus on the second one. How does the initial manufacturing emissions get amortized over? To amortize embodied emissions, one of the natural and straightforward ways to keep the server hardware in use in data center as long as possible.
1:05 And companies actually have already decided to do that. Last year, they reported a plan to use the server for a longer time than before. And this is driven by many factors, such as the shortage of supply chain during COVID. And of course, they want to save money and cost. And this is definitely beneficial to build an environmental-friendly data center.
1:31 And in order to use the servers for a longer time, we need to very understand how they are actually used. And one of the key features for a multi-core CPU server in use is that different cores are used differently. And this is primarily due to the inherent program behaviors, because different cores are running different things. And this is also where the operating system scheduler comes into play, moving threads around, across different cores for different purposes, such as high utilization, free of contention, and so on.
2:09 Here's an example. If a core is overloaded, the scheduler can just move, find the idle core, and perform load balancing. In this paper, we focus on a system setting, CPU affinity, also known as core pinning or processor affinity.
2:31 And so they are basically the same thing. And the operating system bounds a thread to a physical core all the time, which disallows the scheduling I mentioned above. And it has a bunch of benefits, such as improving data locality, reducing data movement, stabilizing latency and throughput. And, of course, it avoids information sharing, so it's kind of improved the security to some degree.
2:59 And the CPU affinity are widely supported in different operating system implementations. And the CPU set, as many of you know, is provided by Linux, which allows you to pin a thread on the core. And in general, broadly speaking, CPU affinity are widely used in many scenarios. And here, we classify them into two groups. In the first group, applications include databases, net view functions, et cetera, use this kind of affinity to get benefits. And in the second group, infrastructure management threads also benefits from affinity in cases such as networking, storage, virtualization, scheduling subsystems, interrupt cores, et cetera.
3:48 So, as we showed, the usage asymmetry in multi-core system has some performance issues. And to fill this gap, the operating system scheduling comes into play and do something useful. And here, we are looking at CPU affinity, which is widely used, but kind of overlooked before. It disallows the operating system scheduling by its nature of affinity, and it also exacerbates the usage of asymmetry, because now some of the cores are running some specific programs all the time. And in this paper, we look at the impact of affinity on sustainability and try to find ways to fill out this gap. Okay, it's much higher than what I expected.
4:34 Yeah. Yeah, according to prior observations, the asymmetry cores usage does have some impact on sustainability. So, here, I listed two hardware phenomena about CPU core wearout. First, the transistors gradually wearout, which leads to slower transistors and slower critical paths due to the continuous movement of charges. And the second thing is that the asymmetry usage across cores in terms of thermal issues also causes the increase or decrease of the threshold voltage. And in order to better understand affinity, the next question is what kind of metrics we should use and helpful for us to measure the lifetime. And ideally, the most accurate way is to use transistor-level information, such as activity factors, charges, threshold voltages, et cetera. But those information are not able to get accessed to by the operating system.
5:43 So, prior work articulates that instructions per cycle, IPC, which represents a core performance, can have something to do with the core's lifetime. So, in our study, we start from measuring IPCs, but differentiating the threads from application threads and infrastructure threads. And then we further measure some microarchitectural features, whereas prior work didn't dive into that level, to explain our findings. We also measure the instructions per second, but not per cycle, which represents the core activity within a fixed amount of time, which is kind of beneficial for us to measure lifetime. And we also measure temperature.
6:33 So, first of all, for IPC, we use several latency-critical applications in data centers, such as Memcached, Redis, RocksDB. And what we found is that they usually have low IPC, usually lower than one. And this is corroborated by a lot of recent studies and papers.
6:56 And we also measure the infrastructure threads, such as polling, router, interrupts, virtualization, scheduling. And what we found is that the interesting part is that the infrastructure threads usually have much higher IPCs than the application threads. And the next question is, why is this happening? We did some microarchitectural analysis. And for those of you who are not familiar with, of course, microarchitecture, it basically consists of a front-end and a back-end. We're in the front-end. We got branch predictor, instruction cache, decoders. And the back-end, we have the execution pipelines, data caches, and interconnects. And we measure the front-end stalls, which means the percentage of CPU cycles where the front-end is idle, not doing anything useful. And for the back-end stall, it means similarly. And what we found is that application usually have that high front-end and back-end stalls.
7:57 On the other hand, the polling thread, as an example of the infrastructure threads, have very little stalls, as you can see in the green bar. Where do those cycles go into for the polling thread? We measure the retire rate of those threads. And what we found is that applications have only, like, 20% to 30% of their retire rate. And on the other hand, the polling has up to 90%. So here, one of our arguments is that although the CPU stall might be a bad thing for performance, but it might be a good thing for sustainability. And in particular, we can use that kind of characteristics to use a multi-core CPU in a more sustainable fashion. And we also measured the number of instruction per second.
8:51 Here, we measured the number of branch instruction per second, because intuitively, the polling thread have a lot of branches in its while loop. And here's the result. Our findings are the polling thread can exercise the core much more often, up to 23 times more often, than the application threads.
9:18 Okay, you might say polling thread is a good microbenchmark. What about an end-to-end application? Here, we measured the TCP echo application on top of the state-of-the-art operating system architecture, DemiKernel. And on the right, this is a stack of DemiKernel where the DPDK polls the NIC's hardware queues. On top of that, we have the application and the transport layers.
9:43 Here's a table of showing results. And we compared the polling microbenchmark with DemiKernel stack running either TCP or UDP. And the first column are the metrics I have mentioned. Here are the results for the microbenchmark. And as for IPC, we can see DemiKernel has lower IPC than the benchmark. But those IPC numbers are still much higher than the applications that has IPC numbers, usually lower than one. For the number of branch instructions, we can see the DemiKernel is even higher than the microbenchmark, probably because they have more complex control flow.
10:28 For the retire rate, the numbers are lower than the microbenchmark, but again, they are much higher than the application threads, whose numbers are around 20%. So these are the other results for the front-end backend stalls. So what we found is that polling thread in this kind of end-to-end system can have some big impact on the sustainability. And especially, sometimes, the number of instructions per second can be even higher than the microbenchmark.
11:00 And the third experiment there is for heat distribution. We still use the DemiKernel stack. And we pin the thread of polling and TCP echo application on core number one, which is shown in this right tiny little square. And we measure the temperature and the y-axis is the temperature in degrees, and the axis is the time. And as we can see, the core number one's heat is much higher than all the other cores, which kind of, from a chip type perspective, just generates heat hotspots.
11:41 And this is also not good for a core's reliability things. And it also consumes more power and energy in a cooling system, because now this chip needs to be cooled down more often. And we give a couple of design options. And here I'm going to give you one of the examples to address the things. And suppose we have a bunch of threads and bunch of cores. Suppose that one is running some infrastructure threads, for example, polling, so that the core number one is burning out. And we propose a new metric called worst time to failure, WTTF. And based on that, we can estimate the core lifetime, and we can integrate a new scheduling subsystem in the operating system, so that once we found this core is burning, we can swap the threads, so that the core, the lifetime of core number one and core number two now become more balanced.
12:44 And if you are interested in the WTTF and our design options, please refer to our paper. So, in conclusion, we look at a question of what's the impact of affinity on system. And through microarchitectural and temperature characteristics, what we found is that the affinity thread does exercise cores intensively and creates heat hotspots. And we also classify those threads into application threads and infrastructure threads, and we found that the infrastructure threads might be more unsustainable than the application thread, because they have higher IPC, higher instruction per second, and higher temperature. And we also propose a new metric called worst time to failure, and provide several design options in the operating system side. Thank you. Thank you. Thank you. Thank you for listening. Yeah. Okay. Yes, that's the microbenchmark we built, and based on what the DPDK, SPDK, or whatever programs are using the polling idea.
14:27 Well, we also measure the polling in the DPDK and more end-to-end system like DemiKernel, and the results shown are from a microbenchmark. Thank you, Mark. Thank you. Thank you very much, Mark.