• Androtheos (unregistered) in reply to Joat
    Joat:
    The real WTF with this solution is going to crop up in 10 years when all the original developers has left the company and the new hire gets tasked with improving the performance....

    They say the funniest things are true. This is hilarious!

  • kylos (unregistered) in reply to Kaosadvokit
    Kaosadvokit:
    2) A scheduled task was added to email the ceo, cto, and developer distribution list the total amount of time lost to this delay in a quarterly report. This amount was expressed in terms of time and the amount of money to employ people for that length of time.

    How much time was lost since the slow down was introduced

  • zwerdlds (unregistered)

    Especially when you could have just called

    usleep()
    instead;

  • Foo (unregistered) in reply to dookdook
    dookdook:
    I don't know php, but why not something like
            $stop=(int)(gettimeofday()["sec"]);
    instead of
            $temp=gettimeofday();
            $stop=(int)$temp["sec"];
    ?

    Unnecessary temp variables irritate me and breaking simple tasks up arbitrarily just makes everything longer and harder to follow. (Not that this is an extreme example or anything)

    Like you say, you don't know the $^&* that is php. While that would work fine in any sensible language, you can't use an index directly on a function call in php, you have to store it somewhere and then index into it. Absolutely no idea why.

  • anonymous (unregistered) in reply to eViLegion

    Take the server home and bring in your raspberry pi...

  • chris (unregistered) in reply to Ash
    Ash:
    Next step, over the course of a few months, increase the slowdown by a small amount every day, say 50ms.
    Sounds like something out of The Twits.:-)
  • Nightwish (unregistered) in reply to Foo
    Foo:
    While that would work fine in any sensible language, you can't use an index directly on a function call in php, you have to store it somewhere and then index into it. Absolutely no idea why.

    Because using a Lexer for your language would make too much sense for Rasmus to do it. Sigh.

  • Paul Neumann (unregistered) in reply to dookdook
    dookdook:
    Pock Suppet:
    And call it my brief and horrible experiences with functional programming, but I'll take a couple intermediate variables which break a process into several obvious steps rather than a blob of parens and commas nested six levels deep.

    Heh, so I'm guessing this excerpt from a personal project of mine wouldn't get me hired in any IT department you were in charge of.

    http://img401.imageshack.us/img401/2144/screenshotfrom201306040.png

    That's

    1. Reading a webpage
    2. Parsing out certain data items from the html with a regex
    3. Filtering out unacceptable items (after checking that filtering is required)
    4. Initializing a set of POD objects for each remaining item and putting them in a list for further processing.

    all in one 16-line statement. IMO judicious indentation makes it perfectly readable.

    (maybe this is why I'm unemployed xD)

    Linq really makes for a more imperative paradigm. My only complaint would be not using the dot-notation in C#. SQLesque Linq should only be used from VB.NET.

  • seafood platitude (unregistered) in reply to trololo
    trololo:
    /* Wait

    Makes the FRIST wait

    @access public

    • @param int the number of seconds to wait
    • @return none */
      function wait($secs) { $temp=gettimeofday(); $start=(int)$temp["sec"]; while(1) { $temp=gettimeofday(); $stop=(int)$temp["sec"]; if ($stop-$start >= $secs) break; } } echo 'FRIST';

    WTF FAIL : you've put the "echo 'FRIST';" outside the function definition scope.

    if the code is from a class then it will generate an error "Parse error: syntax error, unexpected T_ECHO, expecting T_FUNCTION in....", alternatively if the code lifted from a purely functional context it will print "FRIST" immediately ... either way this is a fail

  • tegh (unregistered)

    So this function with a parameter of 1 (seconds) would wait an average of 0.5 seconds before returning, and might even return immediately. Surprised nobody mentioned this yet.

  • Will (unregistered) in reply to eViLegion

    The best part of this is I had to do something similar in the past. Users crack me up.

  • nmare (unregistered) in reply to eViLegion
    eViLegion:
    Why write any code at all? Just underclock the server for a few months.

    Too ugly!

    Can you install a device to slow down the server instead?

  • d.k.ALlen (unregistered) in reply to Gore
    Gore:
    I´m tired of stupid php jokes.

    I suppose I am also... but what can you do with stupid php, except make jokes?

  • katastrofa (unregistered) in reply to TGV
    TGV:
    The real WTF is getting a pizza lunch as a reward. I mean, the salaries are WAAAAAAAYYY higher than the prize of a pizza. Or aren't they? It's like throwing some alms, except this raises your cholesterol. "Here you go, old chap. Well done."

    Pizza is for the devs, the managers will get cash bonuses.

  • (cs) in reply to Blaine
    Blaine:
    That's not a hack, that's a rather clean and straightforward way to implement a requested feature.

    Agreed. The end userbase is clearly comprehension-impaired, but give 'em what they want. I've written loops exactly like that to make "animated art" out of drawing some complicated graph.

  • (cs) in reply to Damadar
    Damadar:
    Probably because that is taking a hammer to a problem that required a screwdriver.

    Code's easier to work with than re-clocking the CPU; can be done dynamically without fear, and doesn't affect any other programs that might be running on the server.

    Stupid problems are best solved with stupid solutions... the more stupid solution, the more obvious it should be to the perpetrator why the problem they've caused is stupid, and HOPEFULLY they'll learn something.

    The other option is to just suck it up, and do what the morons say every time. Sucks to be you if you do that though.

  • (cs)

    I expected the end of the story to be that they needed to re-write it in Java.

  • mag (unregistered) in reply to eViLegion

    How else would you show you were utilizing 100% cpu usage during processing without a while(true) loop?

  • (cs)

    All of this reminds me of the silly voice response things. They voice out "Please wait while I look that up", then emit silly "computer like" sounds that indicate something is happening. Then lo, and behold, they have my account information.

    The fact is that they probably have the database query answered by the time "Please" is spoken ("Please wait" if it is windows based).

    Why do we put up with this idiocy!

  • ih8u (unregistered) in reply to eViLegion
    eViLegion:
    Damadar:
    Probably because that is taking a hammer to a problem that required a screwdriver.

    Code's easier to work with than re-clocking the CPU; can be done dynamically without fear, and doesn't affect any other programs that might be running on the server.

    Stupid problems are best solved with stupid solutions... the more stupid solution, the more obvious it should be to the perpetrator why the problem they've caused is stupid, and HOPEFULLY they'll learn something.

    The other option is to just suck it up, and do what the morons say every time. Sucks to be you if you do that though.

    The users knew what they wanted to see. They wanted to see slow. It's nothing to them how you make it happen -- as long as they see what they want. You can implement that in the stupidest, hardest-to-maintain way possible, or you can cut yourself a break and write a loop or a call to sleep or whatever else you decide is simple and elegant (for lack of a better word).

    I suscipit (captcha) that you and your "stupid solutions for stupid problems" attitude might be the one who is stupid.

  • C-Derb (unregistered) in reply to herby
    herby:
    All of this reminds me of the silly voice response things. They voice out "Please wait while I look that up", then emit silly "computer like" sounds that indicate something is happening. Then lo, and behold, they have my account information.

    The fact is that they probably have the database query answered by the time "Please" is spoken ("Please wait" if it is windows based).

    Why do we put up with this idiocy!

    It's all about managing future expectations. I'd go on, but I'm assuming your question was rhetorical.

  • (cs) in reply to eViLegion

    Did no one know how to sleep() and avoid all that busy-waiting overhead? And what about the progressive conditioning?

    function progressiveDelay($seconds = 3.0) {
    	$deployDate = strtotime("2012-01-01");
    	$optimalDate = strtotime("+6 months", $deployDate);
    	$now = time();
    	if($now > $optimalDate)
    		return;
    	if($now < $deployDate)
    		return usleep($seconds * 1000000);
    	$ratio = ($now - $deployDate) / ($optimalDate - $deployDate);
    	return usleep($seconds * $ratio * 1000000);
    }

    Bam. Self-improving software (that the next generation won't have to dig up 10 years later).

  • (cs) in reply to ih8u
    ih8u:
    I suscipit (captcha) that you and your "stupid solutions for stupid problems" attitude might be the one who is stupid.

    Hmm... you think?

    I mean, I don't advocate simply throwing a stupid solution at a problem first thing. Obviously you try and solve it properly first.

    If you're left with no choice but to do something stupid, you might as well make it obviously stupid, and easily fixable... so its more likely to get fixed that way.

    Removing under-clocking from a server is considerably easier than loading up source code, changing it, recompiling, testing and redeploying. So its stupid AND easier to fix. Either way it's not your problem, as you should have the paper trail which demonstrates that you wanted to do it properly and some fool wouldn't let you.

    Regardless, I don't generally have this kind of problem. Why? I don't know.

    Maybe it's because I'm capable of communicating why something is a bad idea, quickly and effectively, so I don't get forced to implement such things.

    Maybe it's because I've never been tempted to join a cowboy company that employs idiots to fuck shit up.

    Maybe its because if anyone makes me do something stupid they usually end up with egg on their face, with me sorting the whole problem out and smelling like roses because of it.

    Maybe I'm just so stupid that I don't notice the problem? Who knows.

  • n_slash_a (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    eViLegion:
    Why write any code at all? Just underclock the server for a few months.
    Better yet, install a Bitcoin miner and sell the Bitcoins for Friday beer bashes.

    That's certainly a lot more useful than a fucking busy-wait loop.

    Feature comment!!!

  • (cs) in reply to QJo
    QJo:
    The real WTF is users being accustomed to computers being slow.

    I questioned the salesguy on this point once, and he shrugged and said: It's what the buyers want. What?!? How can a slower and less reliable machine be what the buyers want?!? Well, he explained, the user thinks that if the computer isn't spending lots and lots of time thinking hard and racing round and round in circles, then it's not a very good computer. If it responds practically instantaneously to commands to open the email program, open a browser on the screen, find the file you were looking for, typing a character of text into an empty email (a response time of 5 seconds is de rigueur for the latter, apparently), then "it can't be doing much".

    Not just computers. Pay close attention to your car's fuel gauge and odometer. When the needle just starts to move off "F" you have about 3/4 of the tank left. When it hits the 3/4 mark you have about 1/2 tank left. When it hits the 1/2 mark you have 1/4-1/3 of a tank left. Because that's the way people like it. When they made an accurate gauge they got letters complaining about poor gas mileage, so they gave up and now give the public what they want.

  • (cs)

    This is still a WTF. They should have used a sleep function. By NOT using a sleep function, while the application is waiting, it is pegging a CPU core at 100%. By using this form of a wait they are reducing the scalability of their application and increasing power usage. They should have used a sleep.

  • Ken B (unregistered)

    Many years ago, when an O/S (and associated compiler) upgrade caused our build time to drop from 20 down to 5 minutes, we joked that "they must have removed the delay loops".

    Did Arlen work for NCR?

  • Christoph (unregistered)

    sleep (PHP 4, PHP 5) sleep — Delay execution

    Description int sleep ( int $seconds ) Delays the program execution for the given number of seconds.

  • (cs) in reply to Some Damn Yank
    Some Damn Yank:
    QJo:
    The real WTF is users being accustomed to computers being slow.

    I questioned the salesguy on this point once, and he shrugged and said: It's what the buyers want. What?!? How can a slower and less reliable machine be what the buyers want?!? Well, he explained, the user thinks that if the computer isn't spending lots and lots of time thinking hard and racing round and round in circles, then it's not a very good computer. If it responds practically instantaneously to commands to open the email program, open a browser on the screen, find the file you were looking for, typing a character of text into an empty email (a response time of 5 seconds is de rigueur for the latter, apparently), then "it can't be doing much".

    Not just computers. Pay close attention to your car's fuel gauge and odometer. When the needle just starts to move off "F" you have about 3/4 of the tank left. When it hits the 3/4 mark you have about 1/2 tank left. When it hits the 1/2 mark you have 1/4-1/3 of a tank left. Because that's the way people like it. When they made an accurate gauge they got letters complaining about poor gas mileage, so they gave up and now give the public what they want.

    Not my Vauxhall Astra, pal. The gauge is fully accurate, when it shows a quarter, there's a quarter of a tank left. Perfect.

    Oh yeah, I see "gas", that must be what it's like in Merrycur.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    Not my Vauxhall Astra, pal. The gauge is fully accurate, when it shows a quarter, there's a quarter of a tank left. Perfect.

    Oh yeah, I see "gas", that must be what it's like in Merrycur.

    I liked the usage of pal; that was textbook. But a Honda Accord would've been a better choice.

  • AD (unregistered)

    Isn't there in PHP a sleep() function that won't consume the cpu introducing a wait? Even VB had it.

  • GUIF (unregistered)

    The problem isn't speed. It was vague feedback to the user. Sure, you don't want a pop up, but there are many ways to tell the user that the save actually saved something, perhaps a small bit of text "Congrats! It Was Saved! YEA!", perhaps another page "it was saved!". Etc.

  • (cs)

    Why hasn't anyone mentioned a sleep method?!?!?!!?!?!!?

  • Anomaly (unregistered) in reply to chubertdev
    chubertdev:
    Why hasn't anyone mentioned a sleep method?!?!?!!?!?!!?

    Oh god don't get them started *predicts next articles comments will be:

    FRIST!

    Why hasn't anyone mentioned a sleep method?!

    Why hasn't anyone mentioned the presidents daughter?

    Why hasn't anyone mentioned a sleeping method with the presidents daughter?!?

    IT JUST GOES DOWNHILL FROM THERE.

  • Dzov (unregistered)

    Last time I used Turbotax.com, every bit of input was followed by deliberate slow loops to trick you into thinking there is complex logic going on.

  • Buddy (unregistered)

    Done lots of these kinds of hacks.

    I remember in an older version of Excel, the print to file functionality of the printing API was broken in that you couldn't specify the filename. Instead it would popup a dialog to enter the filename. Not so useful if the dialog is on the server side. The solution - use send keys to simulate key presses and enter the file name. Can't do it too fast though or some key presses would be missed, so you'd have to sleep a bit between them. In the rare event that the dialog lost focus because some stupid random system popup stole it, we had a watchman process keeping track of the open windows and forcibly closing them. So many hacks. I'm glad they fixed this in the next version of Office.

    Anyway, I would have suggested putting the delay on the client side.

  • Marty (unregistered)

    Yes, commoners somehow seem to be perplexed by speed. That's what made MS add all the ridiculous flashing animations in Windows - to slow things down. But then when things are too slow they start complaining...

  • (cs) in reply to Ryan Fox
    Ryan Fox:
    Back in the 90s, we needed speed-up loops. Now that it's the future, things happen too fast, so we need slow down loops.
    Did you know that within the scarily recent past, adding such a busy loop in its own thread would actually speed up CPU-intensive Python code? Seriously high WTF factor there, on the level of jaw-surgery-required (and I don't know if they've fixed it yet; it was in the sort of place where fixing it is “non-trivial” without making a good number of people very upset as their weird hacks stop working).

    Bad code by bad programmers is a run-of-the-mill WTF. Awful code by programmers who should know better and that impacts on millions of people… classic.

  • AN AMAZING CODER (unregistered)

    As many pointed out, I questionthese programmers that were "sure" the new software was "way better" when they write 10's of lines of code to accomplish something built into the language (usleep).

  • (cs) in reply to Anomaly
    Anomaly:
    IT JUST GOES DOWNHILL FROM THERE.

    Why hasn't anyone mentioned a sleeping method with the president's daughter while she's flicking her Paula bean with a closed frist?

    Now, I can only apologise.

  • JLR (unregistered)

    This isn't as uncommon as you think.

    I do my taxes every year using the TurboTax online site. There are a number of places where, after submitting some data, you're presented with a "status bar" that advances while you wait. It would display status messages like "checking your return for errors" and whatnot.

    No big deal I figured, it's probably just waiting for the server to process something and return a response.

    Then I noticed that while I was "waiting" for things to finish, that the "Continue" button was already available. Why would it allow me to continue if it was still waiting for the server to process something? So the next time I saw it I clicked continue, and sure enough it let me advance without watching the pointless "processing" animated gif scroll through pre-canned messages.

  • Meep (unregistered)
    Arlen's boss shook his head. "No and no. I tried suggesting those but Jones wants none of those 'ugly' fixes as he calls them. I can't believe I'm saying this...we need to force the web site's processes to slow down, people."

    TRWTF is fucking yes-man managers who won't stick to their guns and fob ridiculous shit off to developers.

    As manager, you have two jobs: manage your team, and negotiate with the team's clients (internal or external). If you're failing at job #2, that's half your damned job.

  • Ryan Vennell (unregistered)

    A) They should have just told the superior "sorry about your luck."

    B) Their solution to the problem is horrifically bad: http://www.php.net/manual/en/function.usleep.php

  • eionrobb (unregistered)

    Of course, if anyone bothered to look at the docs for usleep() they'll see that it wasn't available on windows before php5, which I'm guessing was the target platform since they were moving away from an asp classic code base.

  • jaileout (unregistered)

    I've never used PHP, but shouldn't there be a built-in delay function that accomplishes the same thing without spinning for several seconds? Maybe I'm just being overly pedantic, but this seems like a waste of CPU cycles

  • (cs)

    Why don't they put the server in an overheated dorm room? That should slow it down sufficiently.

  • (cs) in reply to eViLegion
    eViLegion:
    Why write any code at all? Just underclock the server for a few months.

    That was option discussed and rejected in favour of looping logic.

  • A Nerd With a View (unregistered)

    They went to PHP, and that's a good thing?

    Why not go to ASP.Net?

    (Sits back and watches the cage match.)

  • A Nerd With a View (unregistered) in reply to JLR
    I do my taxes every year using the TurboTax online site. There are a number of places where, after submitting some data, you're presented with a "status bar" that advances while you wait. It would display status messages like "checking your return for errors" and whatnot.

    I've seen that elsewhere, too. I remember buying a program to crack MS Word passwords: the actual crack was nearly instant. The developer flat-out said at some point that the status bar was added in to "make it seem like the program was doing something.

  • (cs) in reply to A Nerd With a View
    A Nerd With a View:
    They went to PHP, and that's a good thing?

    Why not go to ASP.Net?

    (Sits back and watches the cage match.)

    Job security. It pays to maintain the WTFs that PHP introduces in a system.

Leave a comment on “The Slow Down Loop”

Log In or post as a guest

Replying to comment #:

« Return to Article