Slashdot Mirror


Idle Loop Optimized

seebs writes "Every so often someone makes a joke about optimizing the idle loop, but this article actually does it. " It's about time too- that process has been eating up clock cycles for to long.

68 comments

  1. My idle loop is already optimized by Anonymous Coward · · Score: 4, Funny

    I run Gentoo.

    1. Re:My idle loop is already optimized by Profane+MuthaFucka · · Score: 1

      That's funnier than the story.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    2. Re:My idle loop is already optimized by NotoriousQ · · Score: 1

      But is it unrolled?

      --
      badness 10000
  2. I rule by Anonymous Coward · · Score: 0

    Yeah.

  3. Eating them up by Deltaspectre · · Score: 1, Funny

    It's always eating them up, right when I need them too!!! The odd thing is it's always decreasing to fit my needs... where are all my spare cycles?

    --
    My UID is prime... is yours?
    1. Re:Eating them up by Anonymous Coward · · Score: 0

      Dude, lose the apostrophe in your sig unless you want to continue sounding like an uneducated moron. Thank you.

    2. Re:Eating them up by Anonymous Coward · · Score: 0

      Yeah, but is your IUD optomized?

    3. Re:Eating them up by Deltaspectre · · Score: 0

      Sig optimized, tyvm :D

      --
      My UID is prime... is yours?
  4. Slashdot only posts Stuff That Matters! by datafr0g · · Score: 0

    Aaaaah!!!

    Got You!!

    APRIL FOOLS!

    --
    "Who says nothing is impossible? Some people do it every day!" - Alfred E. Neuman
    1. Re:Slashdot only posts Stuff That Matters! by jacquesm · · Score: 1

      you know what, I've had it. I'm taking a 30 day break from slashdot in 'return' for all the great stuff that has been posted today.

      ciao guys, see you on May 1st.

    2. Re:Slashdot only posts Stuff That Matters! by northcat · · Score: 1

      Er, this is actually a real article. But stick with the 30 day break, trust me.

    3. Re:Slashdot only posts Stuff That Matters! by kyelewis · · Score: 1

      You'll find the "real article" is indeed an April Fools Joke. Made obvious not only by the lucidrousness of optimising an idle loop, but by the descriptions of the author and the April Fools Day links at the bottom of the article ;)

      --
      - Kye
    4. Re:Slashdot only posts Stuff That Matters! by seebs · · Score: 1

      It is indeed an April Fools joke.

      It also shows some neat things about vectorizing non-trivial examples.

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  5. hah by Xaggroth · · Score: 2, Funny

    finally.. a real post

  6. weiner by Anonymous Coward · · Score: 0

    i win

  7. Welcome to First Post Day! by sterno · · Score: 5, Funny

    Say, I'm curious, are you guys scripting this to post a new article every 5 minutes, or did you find some cheap outsourced labor to pound them out in real time?

    --
    This sig has been temporarily disconnected or is no longer in service
    1. Re:Welcome to First Post Day! by Anonymous Coward · · Score: 0

      You lose.

    2. Re:Welcome to First Post Day! by kjamez · · Score: 1

      india. /*
      i am not lame.
      i am not lame. */

      --
      you can't have everything, where would you put it?
    3. Re:Welcome to First Post Day! by Anonymous Coward · · Score: 0

      action quake 2 is the best game ever probably.

    4. Re:Welcome to First Post Day! by Anonymous Coward · · Score: 0

      You keep telling yourself that.

    5. Re:Welcome to First Post Day! by Anonymous Coward · · Score: 0

      I would agree...but I think kjamez's mom is probably a better game.

    6. Re:Welcome to First Post Day! by northcat · · Score: 1

      This is NOT an April Fools joke. This is real. RTFA.

    7. Re:Welcome to First Post Day! by chefren · · Score: 1

      WHY, WHY, WHY would any sane person spend time optimizing something that doesn't do anything at all? Really, think about it. And then think about the reference to "Top 100 April Fool's Day Hoaxes of All Time" at the bottom of the article.

    8. Re:Welcome to First Post Day! by Lars+T. · · Score: 1
      First of all: there is more optimization in that article than just that of the idle loop (even if the given reason speeding up the generation of that spinning "beach ball of death" is another joke).

      But that "idle loop" actually does something, it increments a counter - and thus calculates a lot of numbers. The optimized, vectorized loop does the same (yes, it does calculate the exact same numbers), just faster. Another victory for AliVec.

      --

      Lars T.

      To the guy who modded me down from perfect to terrible Karma - Apple haters still suck

  8. Grammar! by darth_MALL · · Score: 5, Funny

    "Every so often someone makes a joke about optimizing the idle loop, but this article actually does it."

    The article does what? Makes the joke, or optimizes the idle loop?

    1. Re:Grammar! by jay-be-em · · Score: 1

      Not really a grammar error so much as a grammatical ambiguety.

      --
      "Orthodoxy means not thinking--not needing to think. Orthodoxy is unconsciousness." --Eric Blair
    2. Re:Grammar! by Anonymous Coward · · Score: 0

      No, it's gramm ER .

    3. Re:Grammar! by dgatwood · · Score: 1

      What does my grandmother have to do with this?

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

  9. BASIC by FriedTurkey · · Score: 0


    10 PRINT "I am awesome"
    20 GOTO 10

    1. Re:BASIC by Anonymous Coward · · Score: 0

      10 PRINT "I am Awesome ";
      20 GOTO 10

      slashdot sucks today.

    2. Re:BASIC by Anonymous Coward · · Score: 0
      10 PRINT "I am Awesome ";
      11 PRINT "I am Awesome ";
      12 PRINT "I am Awesome ";
      13 PRINT "I am Awesome ";
      20 GOTO 10

      Didn't you learn anything from the article?

    3. Re:BASIC by Codifex+Maximus · · Score: 1

      10 PRINT "I am awesome!":GOTO 10

      We are trying to optimise remember?! Get with the program.
      Sheesh.

      --
      Codifex Maximus ~ In search of... a shorter sig.
    4. Re:BASIC by Codifex+Maximus · · Score: 1

      Syntax error line 10: Unknown token at end of line.
      10 PRINT "I am Awesome ";

      You are obviously a sickly C programmer! BASIC rox donchaknow?

      --
      Codifex Maximus ~ In search of... a shorter sig.
    5. Re:BASIC by Anonymous Coward · · Score: 0

      When you end a PRINT statement with a semicolon, it suppresses the newline. (And a comma moves to the next field or tab stop. At least it did on 70s micros, which is the last time anyone seriously used BASIC.) That's why there's a blank before the second quote mark.

    6. Re:BASIC by Anonymous Coward · · Score: 0

      sometimes you have to adjust the number of spaces depending on if you have a 40 or 80 column screen for better effect. it doesn't really matter if it's a green or amber screen, just make sure to rewind the tape before pressing play when loading the program, or you'll be searching... forever. and keep both hands on the keyboard, mice are rodents, not input devices.

      frankly, I would expect more from someone with slashdot UID 639. c programmer, sheesh. I can do anything I want with peek and poke from basic.

  10. World's Smallest Slashdot Effect Found by Dynamoo · · Score: 4, Funny
    After a huge run of articles, the world record for the lowest number of hits on a website due to the usually massive Slashdot was recorded.

    The webmaster in question said "yeah, I noticed a couple of extra visitors, but my TRS80-based web server coped just fine.".

    --
    Never email donotemail@WeAreSpammers.com
  11. Going for the record? by chill · · Score: 2, Interesting

    Show some restraint. It isn't necessary to publish EVERY LAST APRIL FOOLS JOKE found on the Internet. Give it a rest already!

    -Charles

    --
    Learning HOW to think is more important than learning WHAT to think.
    1. Re:Going for the record? by MatthewNewberg · · Score: 1

      Too late, I've already done it.
      http://mnewberg.com/content/view/78/2/

    2. Re:Going for the record? by Tony+Hoyle · · Score: 1

      by chill (34294) Alter Relationship on Sat April 02, 12:29 AM

      Especially as it isn't april fools day any more.

      GIVE IT A REST PEOPLE!!!

    3. Re:Going for the record? by Anonymous Coward · · Score: 0

      Slashdot today reminds me of some of my "friends" who insist on forwarding every damned joke that gets sent to them, including a list of recipients' email addresses a fucking mile long.

      Enough already!

  12. Also by The+Spoony · · Score: 1

    You can choose to run something like SETI@Home, or if you'd actually like to make a difference, Folding@Home.

  13. or something by Anonymous Coward · · Score: 0

    foolio - threadcrap

  14. they must have a SlashStory Generator by Fox_1 · · Score: 1

    Slashdot Story Generator only they one the editors have is better, because it actually links to real stories.

    --
    The rock, the vulture, and the chain
  15. I can do even better.... by popo · · Score: 4, Funny



    Today at work I was in a spectacularly smooth (and remarkably energy efficient) idle-loop.

    Fortunately the loop was terminated automatically at 5pm.

    --
    ------ The best brain training is now totally free : )
  16. there is a saying in Russian by Anonymous Coward · · Score: 0

    - which literally means 'diarrhea of words', - which (I believe) is in some weird way applicable today to the /. editors pushing April 1 'joke' stories.

    1. Re:there is a saying in Russian by Anonymous Coward · · Score: 0

      Ummm... English has it too: logorhhea.

  17. to? by Anonymous Coward · · Score: 0

    think you mean too*.

    can we get some editors that can spell?

  18. Yeah, but.... by cmsavage · · Score: 2, Funny

    ...have they implemented multicore support for greater speed and accuracy?

    1. Re:Yeah, but.... by SmurfButcher+Bob · · Score: 1

      Yeah, but the licensing fees will kill you.

      --

      help me i've cloned myself and can't remember which one I am

  19. And now for something completely different. . . . by Anonymous Coward · · Score: 1, Funny

    Isn't it awfully nice to have a penis?
    Isn't it frightfully good to have a "dong"?
    It's swell to have a "stiffy",
    It's divine to own a "dick".
    From the tinyest little "tadger",
    To the world's biggest "prick".
    So three cheers for your "Willy" or "John Thomas",
    Hooray for your "one-eyed trouser snake".
    Your "piece of pork",
    Your "Wife's best friend",
    Your "Percy" or your "cock".
    You can wrap it up in ribbons,
    You can slip it in your sock.
    But don't take it out in public,
    Or they will put you in the dock,
    And you won't come back.

    I thank you!

  20. Where is my TPS report? by neckdeepinspecialsau · · Score: 2, Funny

    Um could you optimize the idle loop? Yeah... that would be great.

    1. Re:Where is my TPS report? by Anonymous Coward · · Score: 0

      They took my stapler..... It was a great stapler..... It was a swingline.....

    2. Re:Where is my TPS report? by BorgCopyeditor · · Score: 1

      Yeah, I've been meaning to talk to you about that. I'm gonna need you to go ahead and stop quoting that movie now, OK? Great.

      --
      Shop as usual. And avoid panic buying.
  21. code snipplet by voot · · Score: 1

    while(1) cout "/.\n"

  22. HALT instruction by Anonymous Coward · · Score: 0

    Would you believe Intel CPUs already have an instruction for optimizing the idle loop?

  23. Uses by ch-chuck · · Score: 1

    Great, this technology will allow me to do nothing even faster and with greater efficiency.

    I hate it when I give a cpu an idle loop, and come back later to find it's not even running, lazy bastard. Seriously, after prototyping a new processor the first test it gets is something like
    0000 jmp 0000, or after getting a VHDL z80 to run in ModelSIM the first thing I did was slowly stepping thru a similar loop to verify it was actually 'fetching and stepping' (manually putting the instruction in the bus since I didn't even have memory, heheh).

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
  24. Taco by Anonymous Coward · · Score: 0

    cmdrTaco, did you read that? you might want to

  25. Anyone else read the whole thing? by CrackHappy · · Score: 1

    This is a joke, but man if I didn't know programming I sure would have fallen for it. It's all so... reasonable.

    Jesus - optimizing the idle loop - the way he ends up doing it just cracks me up.

    --
    1f u c4n r34d th1s u r34lly n33d t0 g37 l41d Capitalization really works: i helped my uncle jack off a horse
  26. It's not all a joke by songbo · · Score: 2, Insightful

    True, the article is partly an april fool's joke. What would you get by optimizing the idle loop? More cycles of the idle loop running in your idle time! But the 2nd half of the article discusses Altivec instructions. And seriously, there's useful information to be found there if you're writing Altivec code.

    --
    There are 10 kinds of people in the world - those that know binary, and those that don't.
  27. Re:It's not all a joke- 4bsd history by Anonymous Coward · · Score: 1, Interesting

    There was a similar one years ago about optimizing the idle loop of 4bsd Unix on the VAX. Turns out there was a real reason to make the change, a bug report was filed and the optimization was implemented. The "broken" idle loop did some computation and then checked to see if there was other work to do. If the computation got faster, then the latency in noticing that new work arrived got lower. Lower latency is usually a goot thing. Note that the techniques expoused in this article might even increase the latency by doing more work in each iteration.

  28. Brilliant! by steveha · · Score: 2, Informative

    I love this sort of thing. The basic idea is silly, but he manages to show some useful stuff and make some valid points while exploring it.

    I remember in the 1980's there was a great article on how to add a GOSUB keyword to the FORTH language. The article evolved the code through four different versions, and each one showed something cool and useful about FORTH. Well, maybe not the last one:

    : GOSUB ; IMMEDIATE

    For those of you who don't grok FORTH, this defines a keyword called GOSUB that does nothing, and does it at compile time so it doesn't get compiled in either. (The article noted that GOSUB FOO is the same thing as just plain old FOO, since FORTH functions are always called as subroutines anyway.)

    Around the same time, I saw an article on how to build your own 64KB memory: take a breadboard, and 65536 8-bit flip-flop chips, plus a 1:65536 multiplexer and a 65536:1 demultiplexer for address selection! The article helpfully calculated how many Watts of power it would take to drive all these chips (a LOT) but it didn't say where one might find a multiplexer or demultiplexer with over 65000 pins on it.

    steveha

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
    1. Re:Brilliant! by AdamWeeden · · Score: 1

      OT but couldn't you use a series of multiplexers/demultiplxers?

      --
      I was quoted out of context in my autobiography...
    2. Re:Brilliant! by steveha · · Score: 1

      couldn't you use a series of multiplexers/demultiplxers?

      Well, in real life you would have to.

      Even a modern ball grid array chip doesn't have tens of thousands of pins; a few hundred at most. Back in the 80's, with the dual inline packages for chips, a few dozen pins at most was the limit.

      So if you were insane enough to use a few thousand 8-bit flip-flop chips to build a memory, you would need to cascade a series of multiplexers and demultiplexers. I'm not really a hardware guy, but here's how I think it would all work. (Corrections cheerfully accepted if I get anything wrong.)

      Suppose you had a bunch of 16:1 demultiplexers and wanted to use those for address select on the chips. Then every 16 flip-flop chips would have a demultiplexer hooked up to them, and you would group the chips in "paragraphs" of 16 flip-flops. You would hook up 16 paragraphs to another 16:1 demultiplexer, and that would be a page of 256 flip-flops (16*16). You would hook up 16 pages to another 16:1 demultiplexer, and so on until you ran out of chips, space on your breadboard, wire to connect them all, etc.

      You would have to organize the various levels of demultiplexers to operate on some sort of a bus. The various address lines from the CPU would have to be connected to all the appropriate demultiplexers so that they all lit up just right to select the one flip-flop chip.

      If the full 64KB memory were ever built using 16:1 demultiplexers, I guess you would need about this many:

      1 demultiplexer to select which 4K bank to access
      16 demuxes to select one page from a 4K bank
      256 demuxes to select one paragraph from a page
      4096 demuxes to select one byte from a paragraph

      Total: 4369 demultiplexers. Notice that we have four levels of demuxes, each one expecting 4 bits of input, and we are decoding a 16-bit address. You send the most significant 4 bits from the CPU to the 4K bank select, the next most significant 4 bits to the page select, the next 4 most significant bits to the paragraph select, and the 4 least significant bits to the byte select.

      In real life you would probably need some kind of buffers to boost the signals; I rather doubt if you could just wire-wrap 4096 demuxes to the CPU's address select lines!

      That's just to handle address select. I'm not going to try to figure out how you would make the 8-bit data bus!

      steveha

      --
      lf(1): it's like ls(1) but sorts filenames by extension, tersely
  29. Ain't it obvious? by nsaneinside · · Score: 1

    Naw, the /. post is referring to itself. It does both.

  30. Another problem by old_unicorn · · Score: 2, Funny

    I'm also worried about the lack of a decent defragmenter for the unused portions of my hard disk....

    --
    ***You learn something Every day. And then you die.***
    1. Re:Another problem by Anonymous Coward · · Score: 0

      Well, the work around that I use is to fill to unused space temporarily with pictures, defragment it, and then remove the pictures. I think it does the trick nicely.

  31. About the optimisations by gothmog666 · · Score: 1

    Sorry man, but the compiler shoulb de doing that.
    Loop unrolling is the _basics_.

    You should worry about better design and readability.

    Auto-vectorization is a step for GCC 4.0, thought.

    --
    I intend to live forever. So far, so good.
  32. Hah! by seebs · · Score: 1
    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/