18 ms·
What's a CPU to do when it has nothing to do?
- samcheng 8y agoThis is really impactful work. Data centers are 2% of US electricity consumption, and a 20% improvement in idle energy usage will cut that by a sizable fraction. (Even if virtualization is intended to reduce idle hardware capacity.)
- deepsun 8y agoWell, if your goal is to reduce electricity consumption, the proper way would be to increase prices for it. It's just there might be easier and faster ways, not only improving idle CPU states.
- laumars 8y agoI hate that approach so much. By increasing prices you're not reducing demand, you're just making it less affordable for people who might need it equally than those who are in better paid jobs etc. I prefer the approach of improving energy efficiency (short to mid term time scale) and investing in greener energy sources (mid to long term) to bide us time until nuclear fusion becomes viable and thus electricity consumption no longer becomes a harmful process. We shouldn't punish people less fortunate than ourselves for our own gluttony - which is all that raising prices would do.
- blihp 8y agoBut raising prices on electricity would spur demand for improved energy efficiency. Consumers are notoriously short-sighted on things that don't impact them directly and immediately. We Americans used to love our V8 engines in our big, boaty cars. Then we had an energy crisis and gas prices rocketed up. For a while, people bought more fuel efficient small cars with 6- or 4-cylinder engines. Then gas prices dropped and people started buying trucks. Then gas prices went up again and small cars became popular again. Then gas prices dropped and people started buying SUVs/crossovers... see a pattern forming?
- mav3rick 8y agoWhile the market kicks into gear many people may lose lives or their livelihood. Capitalism doesn't work instantly.
- blihp 8y agoYou're absolutely right and it does take time. Unfortunately, when dealing with macro-level issues like this, putting in place long-term incentives and disincentives in the form of fines/taxes/etc. has been shown to work far better than just encouraging people to 'do the right thing.'
- adrianN 8y agoYou can increase prices slowly, or announce that you will increases prices in fife years. I find it quite unlikely that people's life will collapse when you increase energy prices by five percent a year or so.
- mav3rick 8y agoPlease try and live in a developing country. 5% is huge for a family that can't make ends meet. I don't want to generalize but utopian ideas seem to be propped up on HN without counting billions of other people and their circumstances.
- adrianN 8y agoLuckily we can get 80% of the way to our carbon goals by completely ignoring developing countries and fixing things in the rich countries.
- peteretep 8y agoHistorically, many more seem to lose their lives in directed economies.
- TeMPOraL 8y ago
- ben_bai 8y agoExcept raising prices is the only thing that has the desired outcome. If PCs use only half the wattage that they used to consume... great now I can afford to run 2 for the same price.
- deleted 8y ago[deleted]
- laumars 8y agoI cannot see that happening on the consumer side of things because consumers have generally* not looked at power consumption as a factor for which hardware to buy nor how many to run. * "generally" because home servers / media centres / etc are often picked for their power consumption. As are mining servers (eg crypto-currency). But these are by far the exception rather than the norm in terms of consumer devices.
- PeterisP 8y agoIt only matters if energy consumption is large compared to cost of the device or otherwise total cost of ownership. If PCs use only half the wattage that they used to consume, then it doesn't meaningfully change how many computers (or how powerful single computer) I can afford, because paying for the computers themselves dwarfs the payment for running them.
- fnord123 8y ago>I prefer the approach of improving energy efficiency (short to mid term time scale) and investing in greener energy sources (mid to long term) to bide us time until nuclear fusion becomes viable and thus electricity consumption no longer becomes a harmful process. Raising efficiency probably won't help at all due to Jevon's paradox: https://en.wikipedia.org/wiki/Jevons_paradox https://en.wikipedia.org/wiki/Jevons_paradox """ In economics, the Jevons paradox (/ˈdʒɛvənz/; sometimes Jevons effect) occurs when technological progress increases the efficiency with which a resource is used (reducing the amount necessary for any one use), but the rate of consumption of that resource rises due to increasing demand.[1] The Jevons paradox is perhaps the most widely known paradox in environmental economics.[2] However, governments and environmentalists generally assume that efficiency gains will lower resource consumption, ignoring the possibility of the paradox arising.[3] In 1865, the English economist William Stanley Jevons observed that technological improvements that increased the efficiency of coal-use led to the increased consumption of coal in a wide range of industries. He argued that, contrary to common intuition, technological progress could not be relied upon to reduce fuel consumption. """
- laumars 8y agoI quite believe that phenomena is true for industry but I would be surprised if it still applied to electricity consumption in consumer devices. The cost of power there is pretty low in real terms (low enough that few consumers will factor the cost of running a device into account for general* computing devices or other household goods) but the collective savings from energy efficient hardware at a national scale is massive. So I couldn't see people buying a second mobile phone or laptop just because it's more energy efficient). The question of datacentres is another matter though. But they only respond to demand from people like ourselves who lease computing time from them / place our own hardware in their racks. * I'm not counting mining (bitcoin et al), home servers, media centres, etc. where it's more likely running costs will be factored into the buying decision. However these are uncommon compared to other hardware like laptops, desktop PCs, games consoles, mobile phones, TVs, fridges, kettles, etc.
- Sharlin 8y ago
- gambiting 8y agoThat's the same argument against making petrol more expensive - because there are people who need it so making it more expensive is somehow unfair to them. Absolutely disagree here - if petrol was vastly more expensive, alternative technologies would have to come down in price and be more popular, so yes, even the poorer people could eventually afford them. By keeping the price as low as it is(and living in the UK it's hugely expensive compared to US and many EU countries) we're allowing huge pollution of the environment for the sake of affordability. Maybe by that logic we should allow coal-fired boilers again? They are still allowed in many places across the EU for that exact reason - because forcing people to switch to natural gas/electricity/ecopellets would punish the less fortunate people. But the "less fortunate" people are going to be fucked the most if we don't work on the pollution, which is sort of impossible if we're stopping the fight because of them in the first place.
- laumars 8y agoThat's not really an equivalent example because there isn't an alternative to electricity where as there is an alternative to driving petrol powered vehicles (electric vehicles, public transport, car share, bicycle, walk, etc). I also don't appreciate your "Maybe by that logic we should allow coal-fired boilers again?" comment when I was very clear in my post - the one you're directly replying to - that we should be focusing on greener forms of electricity creation and energy consumption. If that does also drive up electricity prices then so be it. However artificially increasing electricity prices and expecting the market to do the honourable thing seems like you're trying to solve the problem by changing the end variable rather than fixing the root cause itself and letting market prices adjust accordingly.
- gmac 8y agoYes and no. Policymakers too rarely do anything to show they care about distributional impacts, but you could certainly arrange things so as to fix this. Why not impose a tax that doubles the cost of energy, and use all of the proceeds to fund universal basic income? That would both help poorer people and reduce energy usage.
- pjc50 8y agoWell, the same is true of every price level change, especially in food and housing. I'm sympathetic to the "fuel poverty" arguments, but fuel and energy subsidies are a pretty bad way of addressing the problem. Especially in non-Western countries.
- abecedarius 8y agoGenerally it’s more efficient to help the poor by giving them money, not by distorting prices. Prices are information guiding a giant distributed system; you don’t lie to your OS kernel and expect your programs to run as well. Making energy prices include externalities would encourage the improvements you listed.
- okreallywtf 8y agoMaybe we need progressive pricing?
- ohithereyou 8y agoProgressive pricing of goods/commodities tied to CO2 emissions as a result of their production/consumption would be good. Transportation, energy, industry, and agriculture account for the majority of US greenhouse gas emission. Charging heavy consumers at a progressively higher rate will ensure the heaviest emitters pay their share without disproportionally affecting low income or light emitters.
- TheDong 8y agoUnfortunately that's no longer possible in the united states due to citizens united.
- deleted 8y ago[deleted]
- crististm 8y agoEnergy demand is not elastic so raising prices is not the right way to reduce demand. Raising prices for inelastic commodities does not change the behavior of the consumer.
- mixmastamyk 8y agoWhy do you think it is not elastic?
- crististm 8y agoBecause it is a basic need of today's society. You can't suddenly decide you won't use energy without significant side-effects. It's worse if someone else decides that for you by raising prices.
- mixmastamyk 8y agoDunno, you can go without, shift timing, or buy more efficient devices.
- lathiat 8y agoYour argument makes no sense because it is self defeating. The point of increasing the price of electricity is to increase the incentive to use less of it. How would we use less of it? Precisely by actions such as development time spent on tasks to reduce energy usage.. such as improving the CPU idle states (among many, many other such options).
- Double_a_92 8y agoThe increased cost makes it more impactful for the companies, even if they don't care about the enviroment. So they actually might pay the engineers to do something about it.
- foobarchu 8y agoWhat i'm getting here is that you think the author should stop working on this research, because if he doesn't then maybe companies will start funding him so he can...do this exact research? Science shouldn't grind to a halt just because not doing it might increase funding.
- Double_a_92 8y agoNo, more of the opposite. Companies should support him and others researchers because it's in their own interest.
- maxlybbert 8y agoI don’t see how that’s self defeating. But I understood the comment to be “if electricity cost more, people and companies would be more diligent in turning off lights when they aren’t needed, setting the thermostat to use less electricity, and doing other simple things to save electricity and money.” It wasn’t a question of whether the kernel can do a good job automatically, but whether there is low hanging fruit that we’re currently ignoring.
- MaxBarraclough 8y agoI don't want to sound complacent, but I don't see that 2% is necessarily a bad sign. I suspect that 2% of the power-consumption is integral to well over 2% of the economy, for instance. Improving energy efficiency is always good, of course, but I'm not convinced there's a whole lot of low-hanging fruit that people need to be economically incentivised to implement. That said, there are projects like Erlang on Xen [0] (a bare-metal-ish system) which enable unusual deployment patterns like spinning up a VM only after a request has been received, which could, presumably, make radically more efficient use of virtualised platforms. Not sure if anyone's done this in anger though. Edit: I suppose higher prices would lead more people to do simple things like configuring their test servers to shutdown overnight and on weekends, mind [0] http://erlangonxen.org/ http://erlangonxen.org/ , also https://news.ycombinator.com/item?id=5431392 https://news.ycombinator.com/item?id=5431392
- Twirrim 8y agoHow do you envision that actually helping in this case?
- rmdashrfroot 8y agoYou sound like a California politician
- diffeomorphism 8y agoNaive question here, but how much of the time would you expect cpus in a data center to idle? Also, you save 20% of idle (which is a sizable percentage, but not much in absolute wattage) and nothing when not idle (which is much higher wattage). So how much do you save per month overall?1%, 0.1%?
- Dunedan 8y agoNow we just need to iron out bugs which prevent CPU's to reach certain low-power states. Turns out in modern CPU's that's surprisingly difficult to achieve, as not only the CPU is considered for such power states, but attached components, like the NVMe controller, as well. Matthew Garrett explains pretty good what's happening there: https://mjg59.dreamwidth.org/41713.html https://mjg59.dreamwidth.org/41713.html
- IcePic 8y agoI have no idea on how many other OSes do this, but at least OpenBSD will use idle time to pre-clear memory pages that have been returned to the OS, so that when the next process has them mapped, it doesn't have to zero-fill-on-demand at the very latest moment. It has to be done at some point, but if you keep a queue of pages needing to be cleared and dealing with as many as you can while any core is idle, a non-100% busy system can be seen as to "improve" performance a bit by timeshifting the task to not-directly-after-former process but also not when the new process is calling for memory to be mapped in. But when that list is empty, doing the right kind of CPU sleep is totally worthwhile of course.
- sedatk 8y agoWindows also has a similar thread called “Zero Page Thread” which has the lowest priority on the system (even lower than IDLE, IIRC).
- ovi256 8y ago>lower than IDLE Any idea why that's necessary ? So it's preempted by a IDLE process.
- bonzini 8y agoIDLE is the priority of a process that runs only when the system is otherwise idle. It shouldn't be preempted by zeroing memory.
- na412 8y agoBut then under what circumstances will the zero page thread ever be scheduled?
- blattimwind 8y agoWhen there are no runnable idle threads.
- 8y ago
- aportnoy 8y agoWhy does a CPU have to run? EDIT: > If the hardware doesn't make allowance for this, then the CPU will have to run useless instructions until it is needed for real work. Do any consumer processors (think Intel iBlah) not support turning off the CPU when it's not needed?
- zaarn 8y agoSome cheap microprocessors do that, usually in devices where power consumption matters they have a small companion microprocessor (a micromicroprocessor so to speak) that will power down the big one if necessary and enter a sleep state itself to severely cut down on power consumption (some devices can go as low as microamps). Generally, most modern CPUs support turning off when not needed, however, this is generally referred to as power-on-standby (S3, IIRC). The CPU is off, most things are off, RAM is on. The CPU itself has to continue to run because there is almost no timeperiod larger than a few seconds in which there is truly nothing to do and shutting down CPU cores and clocking the remaining one is efficient enough.
- tomfanning 8y agoA good example of this: http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/ http://www.home-automation-community.com/arduino-low-power-h...
- Already__Taken 8y agoAnother good example are the javascript microcontroller boards. Because of the event-loop model of the Js engine, they can simply see there's no code to run and shift into power saving modes without the dev having to do anything special. example: https://www.espruino.com/Power+Consumption https://www.espruino.com/Power+Consumption
- brokenmachine 8y agoThat's great, I didn't realize there were micros that could do that automatically. Much simpler than the usual mucking around with registers.
- guico 8y agoHangs out on reddit?
- vectorEQ 8y ago20% is much win, very interesting and nice progress on the kernel there! very useful!
- jondubois 8y agoI have a joke. Q: What do you call a CPU which has nothing to do? A: An Intel CPU. Also: Q: What's the best platform for Intel CPUs? A: A warehouse shelf.
- rejschaap 8y agoI don't get it. They have nothing to do because they finish the work so fast that they are idling most of the time? But then the second joke doesn't make any sense at all.
- jondubois 8y agoIt's a business joke not a developer joke.
- sigi45 8y agoI also don't get it?
- jondubois 8y agoThey're supply chain jokes. 1. This is an exaggeration but the idea is that they have nothing to do because no one is buying or using them anymore (since the Intel vulnerabilities were uncovered). 2. A platform is a kind of software. A shelf is a kind of platform (different definition). Before items such as Intel CPUs are sold, they sit in warehouses for a while. Intel is not good for running any software platform so the best platform for them is a shelf... Also alludes to the fact that no one is buying them and that no one should buy them. (Also exaggerations).
- sigi45 8y agoDo you have any numbers on it? I actually haven't read anything about people and companies stopped buying Intel CPUs.
- AstroJetson 8y agoThis is when I miss the days of big iron. The Burroughs B5500, 6500 and 6700 all had massive light displays of registers. The idle process loaded the registers with a bit pattern that showed the Burroughs logo, a circle with a B in it. You could watch the panel and see how busy the system was by how often you could see the logo flash in the lights.
- wglb 8y agoYes! Or the Xerox Sigma 5/7, but that had fewer lights—just one row. Or even the IBM 1800.
- derriz 8y agoThat piqued my interest and I found this delightful video from 1969 on youtube: https://youtu.be/MkxBmviMy_E https://youtu.be/MkxBmviMy_E covering the launch of the B6500. It has some surprisingly interesting technical details.
- AstroJetson 8y agoThanks for posting that. I used to work for Bobby Creech (@4:19) on A Series (follow on to the B6700's), so that was a blast from the past. If you look at this image <img src="http://www.retrocomputingtasmania.com/home/projects/burroughs-b6700-mainframe/gallery/B6700%20dual%20CPU%20MCP%20idle%20light%20pattern.JPG?attredirects=0"> http://www.retrocomputingtasmania.com/home/projects/burrough... its a 2 CPU system, in the lower left is the "B Meatball" idle pattern.
- karambahh 8y agoYour comment got me curious: apparently Linux controls LEDs activity through /sys/class/led [0] A cursory search led me to this project[1] that blinks the power led according to the disk activity, which is not far from your idea (replacing the disk activity by a composite of system load for instance?) [0]https://www.kernel.org/doc/Documentation/leds/leds-class.txt https://www.kernel.org/doc/Documentation/leds/leds-class.txt [1]https://github.com/fabio-d/block-led-trigger https://github.com/fabio-d/block-led-trigger
- malydok 8y agoI appreciate the article being written in a language a person without much CPU knowledge, like myself, can understand. Fascinating.
- jhabdas 8y ago>> What's a CPU to do when it has nothing to do? > Mine Bitcoin! This would be great for CryptoNote Webminers running WASM in the browser to help users understand you don't have to juice every thread/cpu in order to effectively mine at scale using a proxy like the one provided in Webminerpool.
- TheDong 8y ago> effectively mine at scale You mean "in order to spend an extra $2 in power to make 3c for someone else"? Very effective. As long as there are more price-efficient mining pools which are an appreciable fraction of mining power, it will not be cost effective to mine anywhere less efficient since margins will naturally approach what those larger pools can support. A consumer desktop will never be able to compete with a centrally cooled data-centre which likely gets special power rates and was intentionally built in a location power is cheaper in. Especially not if it's having to go through wasm.
- deleted 8y ago[deleted]
- kahlonel 8y agoI once increased coin-cell run-time of a client’s hardware (ARM) platform from 1 month to 1.5 years simply by replacing almost all sleep() functions with low-power-mode-enter.
- ddalex 8y agoI'd argue that, in this context, sleep() itself is buggy
- kahlonel 8y agoThat was a no-OS situation. sleep() is usually implemented as a calculated number of cycles of `nop`s in those SDKs.
- brokenmachine 8y agoSleep is different to low-power mode in embedded devices. Most (all?) microcontrollers have a wide range of low-power modes that disable more and more features of the chip to save power. So if you only need it to do something say once every minute, you can usually save a lot of battery life by using the low-power modes.
- retSava 8y agoAn interesting thing regarding the NOP (no operation) instruction many CPUs have, is that it many times is implemented as a pseudo-instruction. Ie, what actually runs is something that has no effect, eg move contents from a register onto the same register. It has also given name to the human activity of "NOPping", similar to zoning out.
- e3b0c 8y agoDoes it also imply that a non-blocking event loop in the userspace application is energy-inefficient? Likewise, given that some OSes APIs (syscalls) provide both non-blocking and blocking modes, should we prefer the blocking ones concerning energy efficiency?
- jjuhl 8y agoYes. A blocking loop will allow the CPU to power down until an event arrives. A non-blocking/busy loop will continue to burn CPU cycles and the CPU will be busy and cannot reach lower power states.
- imtringued 8y agoThey are pretty much equivalent. The kernel will only schedule your program when an event happens. The difference is that by using a blocking syscall you will need more threads which indirectly decreases energy efficiency through increased context switching and RAM usage. If you only have a single thread then blocking or non-blocking is going to consume the same amount of energy.
- userbinator 8y agoNote that this seems to be about not waking up the CPU (by timer ticks) more frequently, to allow it to go into a deeper sleep --- AFAIK the actual "idle loop" just executes the HLT instruction, which puts the CPU in a "wait for interrupt" state, and for newer CPUs they go into successively lower power states the longer they're halted. This reminds me that earlier operating systems like DOS and Win9x kept the CPU in a busy polling loop when idle --- which was great for responsiveness, but not power consumption nor heat; applications like http://www.benchtest.com/rain.html http://www.benchtest.com/rain.html soon appeared, which replaced the idle loop with an actual HLT loop and actually had a noticeable effect. The DOS version is at https://maribu.home.xs4all.nl/zeurkous/download/mirror/dosidle.html https://maribu.home.xs4all.nl/zeurkous/download/mirror/dosid...
- mjg59 8y agoIt's more complicated than that these days. Rather than HLT, you call MWAIT with an argument that corresponds to the C state that you want to enter - the OS has a better idea than the CPU of how long it's going to be asleep (basically what this article is about), so it can tell the CPU to enter a deeper state. The CPU may make an executive decision based on its own needs to enter a different state (potentially even a deeper one), but it's largely still up to the OS to choose rather than the CPU entering progressively deeper states.
- samat 8y agoThis reminds me of what apple did with scheduler in macOS Mavericks https://www.apple.com/media/us/osx/2013/docs/OSX_Power_Efficiency_Technology_Overview.pdf https://www.apple.com/media/us/osx/2013/docs/OSX_Power_Effic...
- bogomipz 8y agoThe article states makes numerous mentions of the "the governor": >"In this loop, the CPU scheduler notices that a CPU is idle because it has no work for the CPU to do. The scheduler then calls the governor, which does its best to predict the appropriate idle state to enter. There are currently two governors in the kernel, called "menu" and "ladder". They are used in different cases, but they both try to do roughly the same thing: keep track of system state when a CPU idles and how long it ended up idling for." Could someone say exactly what "the governor" is? Its a code path in the scheduler? It wasn't clear to me from reading the article.
- mjg59 8y agoThe kernel subsystem that handles this is called cpuidle: https://lwn.net/Articles/384146/ https://lwn.net/Articles/384146/ . It has two different governors, ladder (which chooses an idle state adjacent to the existing state) and menu (which can choose any idle state)
- bogomipz 8y agoThanks this is really helpful. Cheers.
- cobbzilla 8y agoHow does this work on a single-CPU system? Wouldn’t the various idle checks and governor calls keep the CPU always busy? Or is there some way to turn off something so these instructions don’t mark the CPU as “active”?
- fermienrico 8y agoFreeRTOS or most RTOS use idle time to go into low power or sleep mode. It makes sense in an embedded system which is often powered on batteries.
- bigcheesegs 8y agoThe idle checks all happen in the kernel scheduling code which runs on every CPU/core/hyperthread between doing real work. There isn't a separate core which hands out work or controls them. The kernel knows which CPUs are active because it's the one running things, not because it asks the CPU if it ran any code. On a single CPU system it works because when the current process stops running (calls sleep, does IO, etc...) the kernel looks to see if there's anything else to do, if not, it knows the system is now idle.
- leed25d 8y agoBlinken dem lights.
- wyldfire 8y ago> but ARM CPUs, for example, will also benefit. IIRC the majority of phones out there use tickless config, so the ARM CPUs that benefit here are the server-class ones. But good show, indeed!
- PhasmaFelis 8y ago> Idle states are not free to enter or exit. Entry and exit both require some time, and moreover power consumption briefly rises slightly above normal for the current state on entry to idle and above normal for the destination state on exit from idle. Although increasingly deep idle states consume decreasing amounts of power, they have increasingly large costs to enter and exit. What causes this? I would have thought that "stop computing for a bit" would be a simple thing to do, but I clearly don't know much about processor design.
- esmi 8y agoUsually there is a change in voltage on the processor when the processor changes state. This change in voltage expends energy due to the capacitance of the power rail and the circuit itself (the capacitance of one transitor itself is small but there are billions of them). http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capeng2.html http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capeng2.... Even if there is no change in voltage usually the processor will just leak power while making no forward progress on the program while the various timing circuits change.
- scriptdevil 8y agoI work in CPU design. It all comes down to saving power given how frequent idle-state entries are (especially C1 enters with almost most wait-for-interrupt operations) Stop-computing isn't well defined. As long as the clock ticks, the frontend will keep fetching instructions. Sure you can keep feeding it NOPs, but instead, we save power by entering idle states. The quickest to enter and exit (C1) simply clock-gates the core. Caches are preserved. The next c-state might turn off caches too (and thus incurs the penalty of flushing caches on entry and starting with a cold cache on c-state exit). Further C-states might require even more work to enter and exit but consume much lesser power when in that state. The cpuidle governor decides which C-state to enter since a deep C-state entry and exit may end up consuming even more power than keeping the system running or in C1.
- vagab0nd 8y agoThis reminds me of a story I read from some operating system book: Guys working on an early OS profiled the system and found that one particular routine is taking a lot of CPU time. They worked hard optimizing it but found it didn't improve the overall performance at all. Turned out that routine was the idle loop of the OS. I don't remember if it was a true story or just a joke.