394 points · by reddotX · 8y ago · 144 comments
But when that list is empty, doing the right kind of CPU sleep is totally worthwhile of course.
Dragonfly actually removed it two years ago: http://lists.dragonflybsd.org/pipermail/commits/2016-August/...
- Pre-zeroing a page only takes 80ns on a modern cpu. vm_fault overhead
in general is ~at least 1 microscond.
- Pre-zeroing a page leads to a cold-cache case on-use, forcing the fault
source (e.g. a userland program) to actually get the data from main
memory in its likely immediate use of the faulted page, reducing
performance.
- Zeroing the page at fault-time is actually more optimal because it does
not require any reading of dynamic ram and leaves the cache hot.
- Multiple synth and build tests show that active idle-time zeroing of
pages actually reduces performance somewhat and incidental allocations
of already-zerod pages (from page-table tear-downs) do not affect
performance in any meaningful way.or physically pull the RAM out, keeping it cold with LN2, and stick it into devices designed for reading it all out.
The starting point is that there is stale, useless data in ram. Then a usermode program requests an empty page, and usually when they do this they want to immediately use it.(1) Using non-polluting writes, you have to use main memory bandwidth both for clearing the page, and also for bringing the page back to cache immediately afterwards when the program uses it.
Using writes that just allocate new, cleared dirty lines in cache (like the AMD CLZERO), it avoids both the write (which will happen later, when the lines are evicted from cache, probably after the lines have been used by the program), and the read because the lines are now all in the cache.
(1) And on Linux this is trivially true, because Linux only allocates and clears the page when it is first accessed.
Any idea why that's necessary ? So it's preempted by a IDLE process.
Also, do not conflate the user-thread idle priority class with the (non-)priorities of Idle Threads.
If you look at this image <img src="http://www.retrocomputingtasmania.com/home/projects/burrough...
its a 2 CPU system, in the lower left is the "B Meatball" idle pattern.
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 [1]https://github.com/fabio-d/block-led-trigger
Eons ago I had a small program on Linux that blinked the otherwise-almost-useless scroll/numlock leds based on network i/o activity. It was fairly cool.
I just looked at several severs I have access to at several operators, different physical hardware and distros, none of them has a LED defined for anything other than scroll/numlock
As I said elsewhere, none of the (recent) servers I have access to, most of them Intel based, several distros, etc have anything else than LEDs defined for numlock/scrolllock under /sys/class/leds/, where I'd expect to find the CPU activity LED? What am I missing here?
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.
Raising efficiency probably won't help at all due to Jevon's 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.
"""
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?
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.
Making energy prices include externalities would encourage the improvements you listed.
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.
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).
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/ , also https://news.ycombinator.com/item?id=5431392
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.
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?
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.
Pretty much until the early 2000's, PC processors essentially idled at full speed. There are probably some super-cheap, bottom-of-the-barrel, low-end ARM chips still being made somewhere that can't sleep or down-clock.
The aim was low-power-usage, but they came at it from a different direction. This is referring to the OS control over power-states on a traditional (clocked) processor.
AMULET gained its low-power capabilities from not clocking any unused functional blocks during normal usage, same aim, different strategy.
Its standard fare really. dropping into low power mode in an idle loop has been standard practice for that long also.
In embedded systems, the real difference is how you can schedule your application-level events to make optimal use of the low power states of both the core you're using, the other cores and on-board devices (e.g. FLASHs, ADCs, DACs, etc).
This is how iOS and Android try to have an effect by managing the applications use of timers and wakeups from external devices (interrupts) so as to maximise the 'sleep' time.
https://community.amd.com/community/gaming/blog/2017/11/27/a...
>"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.
I don't remember if it was a true story or just a joke.
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.
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.
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.
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!
It has also given name to the human activity of "NOPping", similar to zoning out.
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 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/dosid...
Likewise, given that some OSes APIs (syscalls) provide both non-blocking and blocking modes, should we prefer the blocking ones concerning energy efficiency?
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.
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.
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.