Comment On The Speed-up Loop

“So what do you think about the opportunity,” Ben’s recruiting agent asked. He thought about it for a few moments. It wasn’t exactly what he was looking for, but then again, he had been out of work since November of 1989 – nearly three whole months – and figured he should probably get back in to the swing of things. He told the recruiter that he’d like to talk to the client and asked to schedule an interview for the following week. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Re: The Speed-up Loop

2008-01-29 09:51 • by Evil Otto (unregistered)
173935 in reply to 172988
Then the user would complain about having to click OK every time they saved something.

Sometimes the clients need to be protected from themselves.

Re: The Speed-up Loop

2008-01-29 21:17 • by EA (unregistered)
174092 in reply to 172961
Actually, the rule is that 80% of the work takes 20% of the time, and the other 20% of the work takes 80% of the time.

Re: The Speed-up Loop

2008-01-31 03:26 • by david (unregistered)
174378 in reply to 173631
It is fake: in 1987, a 1 to 1 million loop would take a very very noticeable amount of time (ie: in the seconds magintude order). Having this for each screen refresh ? I call b*s!t.

Anyway, empty loops in screen updating code on early PC were common because you had "snow" effects if you update the screen too frequently...

WTF? random delays don't solve that problem unless you are lucky. You need to synchronize with the screen update, which you do by hooking an interrupt or looping until the video register clears - not an empty loop

Re: The Speed-up Loop

2008-01-31 03:46 • by david (unregistered)
174379 in reply to 173035
Teh Optermizar:

It tells you that it's 1024 words on the front page

Aha... I came in via a direct link in the RSS feed, so I didn't see that... its only 892 according to Word (904 if you include the title and by-line gubbins)

Obviously this is an indication that Microsoft is short-changing me on words... bastards... :P

Last I knew, editor word count was designed for reporters and other people who actually used it - and it was a letter count, because newspapers and magazine specified, laid out, and paid that way. So 892 'words' in most editors meant something like 3568 characters. Or has that changed?

Re: The Speed-up Loop

2008-01-31 04:11 • by david (unregistered)
174384 in reply to 173086
GCC will not optimize away the empty loop. It is documented as such, because GCC assumes that such a loop is purely for delay purposes, so optimizing it away is undesirable.

gcc can and does optimise away an empty loop, or anything after an absolute return statement. It will optimise away
for (i = 0; i < 1000000;i++);
for (i = 0; i < 1000000;i++){}
for (i = 0; i < 1000000;i++){i=i;}
However, it will not optimise away
for (u = 0; u < -1;u++){
Or other obvious optimisations, even on -Os, and of course suffers from the limitations of the language definition when it comes to optimisation. Part of that has been addressed by changes to the language definition (for example, strict aliasing), but it is still a far cry from languages which were designed with code optimisation in mind.

Re: The Speed-up Loop

2008-02-02 06:20 • by int19h (unregistered)
174787 in reply to 173002
The loop will get optimized by the JIT compiler later on. Most .NET compilers don't optimize aggressively, because they know that all the serious optimizations (e.g. function inlining, even constant folding) will be done at run-time.

The way to check is to run the program in VS and switch to disassebly. Only you first need to find the obscure "Suppress JIT optimizations when debugging" checkbox somewhere in VS options dialog, and turn it off; only then you see what actually is executed when your program runs standalone.

Re: The Speed-up Loop

2008-02-06 04:27 • by Chris (unregistered)
175186 in reply to 172958
It's in the for loop. A signed int is limited to 32768, but the loop goes way further. I feel dumb because i can't remember how to work out how that pointer would look after the loop.

Re: The Speed-up Loop

2008-02-18 14:50 • by Majax (unregistered)
177651 in reply to 172958
in the for loop he increments an int from 0 to 1000000

int i;
for (i = 0; i < 1000000;i++)

problem is an int doesn't pass 65535


Re: The Speed-up Loop

2008-02-18 14:56 • by Majax (unregistered)
177652 in reply to 175186
I think the int would be -32768 if signed or go back to 0 if unsigned.

PS: Sorry, 65535 is the limit for unsigned int Chris is right about the 32767 limit for signed int.

Re: The Speed-up Loop

2008-09-17 09:04 • by Mkay (unregistered)
217843 in reply to 173006
WTF ?!
you don't make a empty loop that is consuming resources (=CPU) and doing nothing (=waiting for some threading variable) !

go and see some thread synchronization methods please and don't spread this nonsense...

Re: The Speed-up Loop

2008-09-17 09:07 • by Mkay (unregistered)
217845 in reply to 173119
sorry forgot the quote the guy with the

someThreadVariable = 400;
while (someThreadVariable != 500);

^^^^ idea

Re: The Speed-up Loop

2009-02-11 20:51 • by robardin (unregistered)
OK, so they're 16-bit integers and (presumably) pointer addresses as well. But without a malloc() or init to a static buffer, won't the line

char *p = 0x10000;

simply result in a pointer to who-knows-where, and the deref in the loop:

*p++ = 0;

an immediate crash? (Or is this some ancient DOS magic memory address for some kind of device or O/S hook?)

Re: The Speed-up Loop

2009-04-06 17:44 • by Daniel Smedegaard Buus (unregistered)
TRRWTF here is that Windows 2.11 was on the market.

Re: The Speed-up Loop

2009-05-28 09:40 • by Toni N (unregistered)
This story is such a classic gem, I keep coming back to read it again and again. The word "speed-up loop" has become a standard term where I work :)

Re: The Speed-up Loop

2009-08-20 13:22 • by Jimmy the Geek (unregistered)
80 20 rule is also known as the Pareto principle.

In software, the 80/20 rule is the ratio between program completion and time. You can get 80% of the work done in 20% of the time. The last 20% of work takes 80% of the time.

Re: The Speed-up Loop

2009-09-21 14:32 • by Kuba
285715 in reply to 172982
uh, wouldn't the compiler optimize that away? i mean, depending on the intelligence of the compiler...
I read statements like this again and again, but I'll be damned if I've ever seen a compiler do that. Ok, ok, I've only used the compiler that comes with (various versions of) Visual C++ but it is supposed to optimize some and even with full optimizations on in a release build it's never optimized anything like this away that I've found.
It will optimize it away. If you just set to Release mode in Visual Studio, that isn't full optimizations. You need to tell it that you want it to run as fast as possible too.

One time, I tried something like this:

while (true);

Set the mode to Release and the optimizations to "Speed" and voila, program runs, no infinite loop.
If any version of VS really did what you wrote, it's a bug, and should be reported yada yada. Hopefully after you re-read your post, it'll be obvious why. This code doesn't "do nothing". It halts. IIRC, C spec does not allow optimizing halts away.

Cheers, Kuba

Re: The Speed-up Loop

2009-10-09 21:06 • by Mark (unregistered)
287624 in reply to 172979
VolodyA! V A:
The funny for me was the google ad on this exact page:

"Slow computer? Speed it up by cleaning your registry..." maybe there is some NumberOfZerosInSpeedupLoop in Windows registry?

I am positive some large? packages use a loop to make you think your getting some real meat when you install...

Take Adobe CS2 - I mean how much does an install really have to do? copy some files and set the reg? Why is this taking 10-15 mins!!

Watch it sometime. No disking, no cpu. Its a scam!

Re: The Speed-up Loop

2009-10-09 21:40 • by Mark (unregistered)
287625 in reply to 173146
Oh, i've done that.
Someone complained that sometimes, saving a file was to fast, so he didn't know if it was succesfull, since the statusbar popped in and out to fast.

If filesize < 2mb
open FakeSaveAnimation.gif

There is an ENORMOUS difference between slowing things down for the sake of making you and your department look better, and slowing things down to let the user know something happened.

I agree with you, to be truly ethical such loops (without another purpose like synchronisation, interfacing with a human, etc) shouldn't be used as a general rule of thumb.

On the other hand, if your boss is milestone minded and only pays attention to say runtime (or other very small minded and limited statistics) techniques like the above can be useful to show that progress is being made. To be ethical in this case you actually need to have made progress with program faults/refactoring/scaffolding.

It would also be useful in punishing your bosses for a really crappy design decision, you can simply slow the program down.

boss: Why is the system so slow?
tech: Well you know those changes to the xyz runtime...
boss: yes?
tech: They don't fit there, we need to move them to abc (the right place)
boss: Will that speed it all up again?
tech: Pretty sure.

(Note: you really only should punish them, if you are very certain it won't work/work well. You shouldn't use it when your simply not getting your way, doing something your uncertain of/don't want to do)

Sometimes you need to get people to respect your knowledge and skill.
Sometimes you can only do it by hitting them - even though we don't really want to.
, it's the difference between being paid to make a crappy house, and being paid to make the house they really will like and need.

"Sometimes you need to get people to respect your knowledge and skill. Sometimes you can only do it by hitting them - even though we don't really want to."

Omg, lol. You lie!

Re: The Speed-up Loop

2011-11-11 12:58 • by forch (unregistered)
366546 in reply to 172961
Benjamin Normoyle:
I thought 80/20 was how to completely bullshit situations: when you need a percentage, use either 80 or 20 percent as your number. E.g. : "80 % of this department is slacking off," "20% of companies give free soda to their employees," "20% of experts say YO MAMA."

It's actually 80% of a projects work is done in 20% of the calculated time, the rest of the 20% takes up 80% of the time ;)

Re: The Speed-up Loop

2011-12-02 03:59 • by StJohn (unregistered)
I admit doing this on a web application some seven years ago.
I just added a wait function, setTimeout(), with random time between say 500 and 5000 ms when saving a form. This way the waiting changed everytime and made it less obvious that the application was unoptimized.

Then I just tweaked the values down a bit to improve speed.

Re: The Speed-up Loop

2012-07-31 10:24 • by Cbuttius (unregistered)
385983 in reply to 172964
It isn't a speed-up loop of course, although I would use sleep() to not absorb CPU.

It's what is known in the market as the discriminatory pricing model, and it works in a way that you extract from people what they are willing to pay.

So sometimes you purposely provide an inferior product so people who don't want to pay you as much can still have a product that works, whilst the rich ones will pay you more for a superior one.

Normally that applies where you have a large market and want to sell to as many people as you can, but in this case it is sort of twisted to work for the current employer. Pay us more and we'll make your app faster..

Of course, here as they are "removing a 0" each time, it will only work until they run out of zeros to remove so they'd better have this in several places.

Re: The Speed-up Loop

2012-08-06 08:29 • by agtrier (unregistered)
OMG! I think I was working as support for the same application. Seriously!

Re: The Speed-up Loop

2012-08-06 08:31 • by agtrier (unregistered)
386427 in reply to 366546
In my experience, the first 80% of the project take up 120% of the time, the other 20% take another 80%.

Re: The Speed-up Loop

2013-06-06 11:03 • by ObiWayneKenobi
A job like this would be a godsend in the modern day. 1 hour doing menial tasks, and the rest of the time could be spent learning the latest and greatest newfangled JavaScript frameworks or whatever. The only thing better would be a super lax IT environment where you could play games and stuff on your computer.

Get a fat paycheck for 1 hour of work and 7 hours of doing whatever you want? Fuck yes. Call me unethical all you want, but you know that would be paradise.

Re: The Speed-up Loop

2014-04-27 07:13 • by Lol (unregistered)
432025 in reply to 172961
Several year late reply, software engineer here from the future. The 80 20 rule is that. 80% of something in a business is caused by 20% of something. It is kind if a joke rule, but seems to hold true nonetheless. E.g 80% of bugs are caused by 20% of employees. 20% of sales are caused by 80% of employees and so on. Wikipedia it. Not sure if we had that in 2008... I think we did but people complained about reliability of citations.
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Add Comment