[HN Gopher] What does an idle CPU do? (2014)
       ___________________________________________________________________
        
       What does an idle CPU do? (2014)
        
       Author : ivanvas
       Score  : 125 points
       Date   : 2022-06-26 19:36 UTC (3 hours ago)
        
 (HTM) web link (manybutfinite.com)
 (TXT) w3m dump (manybutfinite.com)
        
       | iasay wrote:
       | On my Windows laptop, Windows Defender is the devil waiting for
       | idle hands.
        
         | Rodeoclash wrote:
         | My gosh this. I recently had Windows update on my sons laptop,
         | a 2012 "hand me down" Thinkpad. We'd composed a song together
         | in Ableton that used 4 soft-synths and after the update it
         | could not play the song without pegging the CPU!
         | 
         | I eventually tracked this down to Windows Defender sitting at
         | 40% CPU! Disabling it entirely brought the performance of the
         | laptop back to what it was pre-update.
         | 
         | I find this behaviour extremely disappointing. This is a
         | perfectly serviceable laptop that would have likely been
         | replaced by someone who was less technically inclined had it
         | happened to them and they did not have the wherewithal to track
         | down the offending piece of software.
         | 
         | Your original quote reminded me of a Cormac McCarthy quote
         | which seems to apply to the Windows Defender engineers right
         | now (I kid):
         | 
         | > But when God made man the devil was at his elbow. A creature
         | that can do anything. Make a machine. And a machine to make the
         | machine. And evil that can run itself a thousand years, no need
         | to tend it.
        
           | seanw444 wrote:
           | It's crazy because even slightly heavier Linux distros run
           | smooth as butter on laptops that Windows chugs resources on.
           | There's nothing fancier about Windows. There's literally no
           | reason for it to be as poorly optimized as it is, and yet it
           | is. It's crazy to me.
        
             | ticviking wrote:
             | The reason is simple. It doesn't impact Microsoft's bottom
             | line. Poor Linux performance will eventually annoy someone
             | enough to fix it, and being open source they actually can
             | fix it
        
       | 3a2d29 wrote:
       | Anyone know other resources like this? I am currently in the
       | middle of learning about Operating Systems by reading my
       | roommates old CS textbook and doing his projects. Would love to
       | look at stuff like this because I just learned a chapter on
       | interrupts and this supplemented it well.
        
         | mhh__ wrote:
         | Hennessey and Patterson contains a little bit of soft
         | information/intuition like this (as well as the computer
         | architecture)
        
       | userbinator wrote:
       | In DOS and Win3.x/9x, I believe the idle is instead an input
       | polling loop. That's why VMs running those OSs will appear to be
       | taking a full host core all the time, unless a special "idle TSR"
       | utility is used.
       | 
       | I'm not sure if that polling instead of interrupts is also
       | responsible for their perceived lower input latency relative to
       | other OSs of the time.
        
         | baisq wrote:
         | Yes, I remember having to install a 3rd-party application to
         | stop Windows 95 or 98 inside of a VM from using my entire host
         | CPU.
        
       | [deleted]
        
       | tiffanyh wrote:
       | People make the argument that unused RAM is wasted RAM.
       | 
       | I wonder if the same logic applies to CPUs.
       | 
       | Unused clock cycles is wasted CPU.
        
         | tails4e wrote:
         | Idle CPUs use much less power, so no its not wasted in that
         | sense.
        
       | Graffur wrote:
       | Does anyone know if projects that aim to use CPU idle time are
       | actually useful?
       | 
       | One example I found: https://einsteinathome.org/
        
         | colechristensen wrote:
         | Folding@home list of published results
         | https://foldingathome.org/papers-results/?lng=en
        
       | tibbydudeza wrote:
       | In the days before MMU's and fancy DRAM controllers and newer
       | DRAM chips the CPU had to do memory refresh during "idle" time.
        
         | tyingq wrote:
         | Depends on what point in time you warp back to. There was a
         | point where most home computers had static RAM.
        
           | Tuna-Fish wrote:
           | Er, when? Apple II was sort of the first big successful home
           | computer, and it had DRAM (The CPU and the display accessed
           | the ram on alternate cycles, and Woz placed the display
           | buffers so that most of the refresh was "free").
           | 
           | As far as I can tell, all the actually widespread successful
           | computers after that have used DRAM too.
        
           | randombits0 wrote:
           | Oh, look at Mr. Moneybags over here!
        
           | tibbydudeza wrote:
           | Yep but cost and when memory starting exceeding 64K.
        
         | Cerium wrote:
         | I don't believe it. A quick search seems to indicate that the
         | IBM PC 5150 triggered memory refresh via timer hooked up to an
         | interrupt which would trigger the refresh hardware without cpu
         | support.
        
           | tibbydudeza wrote:
           | There were computers before the IBM PC you know :).
        
         | Pulcinella wrote:
         | A absolutely great visualization of this (or at least how the
         | execution of an instruction by the CPU is affected by memory
         | refreshing) is this video about the SNES. Video link has
         | timecode, but it should be at 8:23.
         | 
         | https://youtu.be/Q8ph2OVqZeM?t=504
         | 
         | I find it really gives you some context. Memory is refreshed
         | many, many times a frame, roughly once per scan line on a CRT.
         | 
         | Edit: Though it's unclear to me if it's the CPU actually doing
         | the refreshing or if the CPU is just waiting until the refresh
         | is complete.
        
         | dragontamer wrote:
         | You are scaring me. Please, I need to be able to sleep later
         | tonight. Warn before posting such a horror story!!!
        
       | frank_bb wrote:
        
       | randyrand wrote:
       | I still don't really see the need to wake up every 4ms when all
       | processes are suspended or killed.
       | 
       | Just halt the CPU permanently until the next interrupt.
       | 
       | 4ms interrupts are only needed when there are multiple active
       | threads that need preempting.
        
         | kevingadd wrote:
         | Modern kernels are tickless like you describe.
        
         | smcameron wrote:
         | I mean, a couple paragraphs down, the article says:
         | 
         | > The solution here is to have a dynamic tick so that when the
         | CPU is idle, the timer interrupt is either deactivated or
         | reprogrammed to happen at a point where the kernel knows there
         | will be work to do (for example, a process might have a timer
         | expiring in 5 seconds, so we must not sleep past that). This is
         | also called tickless mode.
        
       | shric wrote:
       | (2014)
        
       | mcdonje wrote:
       | >Whenever you write an if statement, Nyan Cat cries.
       | 
       | If I ever offended Nyan Cat, then I'm very sorry.
        
         | mhh__ wrote:
         | But why does Nyan cat get upset? Is this a bad nod towards
         | branchless programming?
        
           | jhgb wrote:
           | > branchless programming
           | 
           | On that note, why aren't we calling it "bamboo code"?
        
         | silisili wrote:
         | While I offend Nyan Cat,
        
           | politelemon wrote:
           | Do until Nyan cat is offended
        
           | contravariant wrote:
           | Not sure if this loop ever exits.
        
       ___________________________________________________________________
       (page generated 2022-06-26 23:00 UTC)