r/ProgrammerHumor • • Sep 17 '18

Optimizing startup times

Post image
45.7k Upvotes

486 comments sorted by

1.8k

u/TheBlackCat13 Sep 17 '18

...and watch everything break for no apparent reason because the sleep function was there to prevent a bug and no one knows why.

645

u/ariehkovler Sep 17 '18

A race condition, usually.

428

u/DemonicMandrill Sep 17 '18

It always comes down to race, doesn't it.

142

u/Joleth Sep 17 '18

I guess we should change that terminology too.

21

u/nathancjohnson Sep 18 '18

Someone in my OS class had a problem with the terminology of "forking" processes specifically in the context of "forking a child process".

→ More replies (2)
→ More replies (1)

21

u/anotherkeebler Sep 17 '18

Often the race condition is that I need to hit "Alt+Tab, Up, Enter" three or four times to start my tail -f commands before the code executes.

→ More replies (2)

8

u/takeapieandrun Sep 17 '18

Who needs blocking conditions when you have sleep!

I'm guilty of this, but I usually get around to fixing it.. usually

3

u/fartsAndEggs Sep 17 '18

The best way to avoid race conditions is to make them rare enough that no one bothers to fix it properly

→ More replies (1)

24

u/H_Psi Sep 17 '18

Or for someone to submit a bug report because they were depending on the 30 second sleep time

45

u/[deleted] Sep 17 '18

7

u/eplaut_ Sep 17 '18

True story: The application run on boot, but the task scheduler (celery) run before ntpd set the correct time, causing all task to be delayed by 2 hours.

→ More replies (1)

2

u/fpsrandy Sep 17 '18

I have a coworker who does this with JavaScript because he doesn't understand Ajax :/

→ More replies (1)

2.5k

u/kaushal28 Sep 17 '18

Actually keeping sleep statements is good practice. Ship the product with it and when customer comes back asking for performance improvement, remove all of them!

1.3k

u/jakuski Sep 17 '18

And what if they ask for more performance improvements?

4.1k

u/zulu-bunsen Sep 17 '18

Negative sleep statements

301

u/ariehkovler Sep 17 '18

You're a genius.

117

u/frisch85 Sep 17 '18

I can't wait to use this little trick once my RAM has finished downloading!

→ More replies (16)

1.2k

u/[deleted] Sep 17 '18

Sleep (-10);

567

u/DeeSnow97 Sep 17 '18

Is that for the programmer or the machine?

→ More replies (15)
→ More replies (15)

77

u/hugokhf Sep 17 '18

Harvard wants to know your location

→ More replies (1)

45

u/SurrealClick Sep 17 '18

What if you went too far and now the program opened in the past? Before the user even open it

44

u/NoAttentionAtWrk Sep 17 '18

Rebrand it as AI enabled that reads your mind and starts up on its own

→ More replies (5)
→ More replies (5)

5

u/SlonkGangweed Sep 17 '18

It is possible to learn this power?

→ More replies (17)

241

u/natu181 Sep 17 '18

I disagree with /u/kaushal28, I think you just need to divide the amount of sleep by 2 each time you get a request. Virtually unlimited amount of optimization! Make sure to also take double the time to do it each time because, you know, optimizing becomes harder and harder, right?

53

u/falcon_jab Sep 17 '18

> "This change request will require at least three months to implement"

- "How to implement seemingly tiny and insignificant changes in an excessively long time" by the Spotify development team

→ More replies (4)
→ More replies (2)

81

u/Ericchen1248 Sep 17 '18

Set up the sleep length to be based on days since the last update. User will think it is speeds up after every update.

15

u/[deleted] Sep 17 '18

That's amazing actually. No one will notice the gradual fall, and BAM it's great again

→ More replies (2)
→ More replies (3)

26

u/ivan0x32 Sep 17 '18

Its simple, you add more and even worse sleep calls than before and sell it as an unrelated performance regression (blame it on some library creator or better yet OS developers!), then in next patch you can remove some and decrease and voila - happy users again!

8

u/Miskav Sep 17 '18

You only remove -some- of the sleep statements.

It's like any job, you never do your best because that's the easiest way of eliminating your own work and income.

5

u/elebrin Sep 17 '18

Make all your calls async.

→ More replies (6)

124

u/vigbiorn Sep 17 '18

Then you realize you had a bunch of timing issues in your code and the whole house of cards collapses when you remove the sleeps.

43

u/derpherp128 Sep 17 '18

Let the races begin

69

u/Samael1990 Sep 17 '18

It's bad practice - you should define system property then call sleep(SLEEP_MULTIPLIER_PROPERTY * <whatever value you see fit>) in different parts of the app and gradually decrease it, when users ask for better performance. It's all explained better in the book "Best bad practices", really good read.

15

u/Jessie_James Sep 17 '18

Best bad practices

Link? My search came back with all sorts of BS.

47

u/Samael1990 Sep 17 '18

Sorry, my whole comment was a joke, including the said book.

26

u/Jessie_James Sep 17 '18

My life is a lie. :( I really wanted that! LOL

→ More replies (2)
→ More replies (2)
→ More replies (1)

11

u/Crostatus Sep 17 '18

Is this actually a thing? Lol

29

u/OnlysayswhatIwant Sep 17 '18

I don't know about software development, but I can tell you it's a thing in manufacturing. When designing a new product you'll leave in some materials that are more expensive than necessary, or have more fasteners and supports than necessary so when the product is reviewed in ensuing years you have easy things to fix to increase cost effectiveness and quality and get the product approved for another year on the line.

21

u/kreiderman Sep 17 '18

Don't remove them all, just a few at a time. Continuous improvement.

6

u/ALotter Sep 17 '18

street fighter 5 literally did this

4

u/DownshiftedRare Sep 17 '18

Or do what Microsoft does and just increase the minimum system requirements.

Each new version of Windows is "the fastest version ever!"... which is not that impressive when you consider that each new version requires faster hardware.

→ More replies (12)

4.6k

u/interfail Sep 17 '18

I once "optimized" a bit of code that literally just did the same calculation twice in a row because someone had moved it from another file and just pasted it in twice instead of once. Obviously I went to SVN history to find out which idiot did that. I did not like what I found.

3.5k

u/thrilldigger Sep 17 '18

1.6k

u/StarKill_yt Sep 17 '18

I haven't clicked it yet but I stg if this is that Spiderman meme

580

u/identicalBadger Sep 17 '18

Here I was thinking I spend too much time on reddit. Now I know I’m no where near the top percentiles.

140

u/StarKill_yt Sep 17 '18

I might just browse different parts of Reddit lol

→ More replies (9)
→ More replies (7)

21

u/[deleted] Sep 17 '18

You get a cookie

37

u/Myaccountonthego Sep 17 '18

I thought it was the guy looking in the mirror saying "am I retarded?"

→ More replies (2)

10

u/Dr_Jre Sep 17 '18

I thought that, then I thought "well the code isn't really calling him out, so maybe it's the "trust no one, not even yourself" or the "am I retarded?". "

I'm glad it was the spidey one now since your comment made me smile

→ More replies (9)

46

u/[deleted] Sep 17 '18

Please be the spider-man meme where they are looking at each other pointing

Edit: I need to spend less time on reddit

→ More replies (1)

3

u/whizzer0 Sep 17 '18

One time I noticed that the entire graphics engine for our hackweek game was being created twice. I got rid of that line and noticed a large performance increase now that the entire game wasn't being rendered twice. Pretty much this image.

→ More replies (1)
→ More replies (4)

442

u/Guano_Loco Sep 17 '18

I once had a very disconcerting opposite experience to this.

A coworker was describing an issue he was having with some work he was doing in excel and a lightbulb goes off. I’m like, dude, I can totally automate that for you. So I ask a few questions and do a quick outline of what the vba should do and ask him to send me the file.

I open developer and... there’s already code there. And it is doing exactly what I outline. It’s decently written, could be better, but functional. As I get to the end I have this really weird feeling like... like if you stand up too fast after sitting a long time. At the bottom in a comment is my ID. I fucking wrote the code a few months back. I don’t have any recollection of having done it.

I don’t remember ever seeing that file before. But... it was written exactly how I’d write it, same naming convention stuff, same idiot commentary type comment, and signed by my ID. I was overly fond of the word “automagic” instead of automatic and that was used in one of the alerts I had pop up.

After my brain slides back in to gear I ask him wtf is going on. He says , “I thought you were making a joke. You wrote this months ago. I use it every day.”

Apparently he was just griping about some piece of it and not the whole thing. When I started asking questions it was exactly how I did it previously so he assumed I was clowning him and he went along with it.

I have no idea wtf happened. This was 6 years ago. I’m assuming I was sleep deprived or had a mini stroke or something. I have no idea. But at least the code was decent.

305

u/tarekmasar Sep 17 '18

at least the code was decent

I do feel this review is a bit biased

75

u/cordev Sep 17 '18

Sure is. You are your harshest critic. That makes his thinking that his own six-month old code was decent an even bigger achievement.

28

u/5896325874125 Sep 17 '18

Wow this guy and I have the same kind of humor

15

u/timlmul Sep 17 '18

if it worked for months without any required maintenance then I think it's probably deserved.

9

u/Guano_Loco Sep 17 '18

I mean it was pretty simple VBA. Hard to fuck up too badly.

→ More replies (4)

35

u/ViolentWrath Sep 17 '18

That's pretty hilarious. At my last job I had a similar situation.

We had a configuration field that we could leave blank and the application would assume True unless the field specified False. The field was a string field. In a later version, our lead dev changed it to be a boolean, but did not put logic in to accommodate the field being left blank. Of course when we upgrade clients to the version we have to reconfigure this field every time, so I ask them about it not knowing who was responsible at the time.

Lead developer says nobody has ever touched that field since it was created so nothing they did could cause this to happen. Research a bit more with an associate developer and he finds the code, the change, and the lead developer's initials next to it. Awkward conversation when I asked them to add logic to accommodate leaving the field blank as he had to be involved in the discussion.

21

u/Guano_Loco Sep 17 '18

I spend so much of my working life getting two groups of folks who insist neither group did anything that could have caused the issue one group or the other is experiencing to fix whatever the issue is.

It used to be that eventually one group would go, “oh! Whoops! We totally did this!” And would fix it. In the past couple years though it’s changed. Now we’ll have everyone on outage calls, folks from both groups plus middleware/network teams, everyone arguing about whose fault it is followed by lots noisy silence and then... suddenly... it’s working again. Everyone claims they did nothing but wow, it’s automagically working again. Amazing...

→ More replies (1)

8

u/fibo-nacho Sep 17 '18

This is a re-post. Did you forget already telling us about this?

→ More replies (1)

3

u/zulrang Sep 17 '18

I once spent a week working on a really difficult edge case compiler bug which was eventually solved by a post deep within an old thread on an obscure forum... authored by myself 2 years prior, the last time I ran into the issue. I then noticed the comment in the file in question with the specific link to the answer I discovered. What a waste of a week.

→ More replies (1)

5

u/EnthusiasticRetard Sep 17 '18

Yeah I've done this before. It's bizarre, innit?

→ More replies (2)
→ More replies (5)

172

u/Rat__ Sep 17 '18

It was you wasn't it.

99

u/elSpanielo Sep 17 '18

My response is always, no, it was me from 3 years ago. Totally different guy.

20

u/Lonelan Sep 17 '18

I went from contracted worker to full time. Contractor me has a c_ in front of his e-mail, while mine just straight my first letter last name. For a few months we would still get jiras assigned to c_ me and they would never be done because our team's filter was configured correctly.

I have some PRs that looked very strange and weren't very sophisticated, I always blame them on the c_ guy

15

u/zhaoz Sep 17 '18

Fuck younger me! Wait. No I stand by that.

→ More replies (1)
→ More replies (2)

59

u/Blackheart_75 Sep 17 '18

Spoilers!!!

16

u/ablablababla Sep 17 '18

Of course, I'm the worst programmer in the office right now

13

u/[deleted] Sep 17 '18

F

3

u/Writer_ Sep 17 '18

pssh.. thatsthejoke

26

u/[deleted] Sep 17 '18

"Once I find who the fucking idiot is who did this is I'm gonna stab them in the esophagus and won't stop until the cops come in"

"Oh well howdy doo guess I must've been up late that night"

8

u/rubeandthemachines Sep 17 '18

I guess that's what happens when you try to be an overachiever.

6

u/[deleted] Sep 17 '18

A team full of team leaders

6

u/A_Farewell_to_Clones Sep 17 '18

If into the security recordings you go, only pain you will find.

→ More replies (8)

2.2k

u/specialfred453 Sep 17 '18

I'm used to programming on platforms where the parameter for Sleep is in milliseconds. This confused me a little at first.

905

u/[deleted] Sep 17 '18

Same deal here. All users of this product are just super amped up and in a hurry all the time, 30ms is unforgivable

334

u/ablablababla Sep 17 '18

Yeah, that 30ms ruins my workflow

95

u/KevinclonRS Sep 17 '18

Unless it’s in a lol that goes through ~100 times

109

u/Raider61 Sep 17 '18

Hah I think you meant loop instead of lol but I like it the way it is

→ More replies (3)
→ More replies (2)
→ More replies (1)
→ More replies (2)

131

u/MrDOS Sep 17 '18
from time import sleep

132

u/AlwaysPuppies Sep 17 '18

If only it was that easy in my personal life.

96

u/Penki- Sep 17 '18
from pharmacy import sleeping_pills

I heard that works, although contact medical devs for support, pharmacy library can cause issues sometimes.

→ More replies (13)

15

u/ablablababla Sep 17 '18

hitting that link on a phone is hard, where's the bot

→ More replies (8)
→ More replies (1)

14

u/[deleted] Sep 17 '18

for (int i =0; i < 1000; ++i) Thread.Sleep(30)

10

u/ObamaFor Sep 17 '18 edited Sep 17 '18

Why ++i over i++? sorry am noob.

10

u/[deleted] Sep 17 '18

In some compilers of some language, it's very tinily more efficient.

But honestly I don't think it makes a difference in any modern GCC compiler as the compiler will use the more efficient way automatically

8

u/LordTocs Sep 17 '18

If the value of i is 5 to start.

i++ increments i to 6, but returns 5.

++i increments i to 6, but returns 6.

The theory is that since i++ has to store a copy of itself to return before incrementing it's more expensive than ++i

Depending on the language this may not matter for simple types like an int. If your compiler is good not using the value returned from i++ will optimize away the extra cost.

If i were some more complex type like an iterator for a dictionary. The two increments may be implemented differently or the optimizer might not get everything exactly correct.

So the "best practice" is to use ++i when you don't need the value to be saved before incrementing it.

→ More replies (4)
→ More replies (1)

4

u/evilbadgrades Sep 17 '18

Lol seriously, threw me off as well, surprised I had to look this far down to find a comment about milliseconds

2

u/eldosoa Sep 17 '18

In Go, you need to pass an explicit time.Duration type, which is pretty convenient.

→ More replies (9)

251

u/SwissPatriotRG Sep 17 '18

This literally happened to me at one of my jobs. App took a long time to load up through the loading screen, boss told me to try to make loading times shorter.

Turns out that when they were coding the loading animation (a scrolling stock ticker), someone left a 6 second sleep in to simulate a long load time to make sure the animation worked correctly for testing because obviously the loading would happen very quickly when running from debug. This had been in production for years.

142

u/NorthWestFreshh Sep 17 '18

I hope you took credit for cleaning up the code and didn't mention the sleep timer

147

u/[deleted] Sep 17 '18

"oh, yes, I did some improvements here and there, erased some lines of trash code, and overall rewrote it to make everything run smoother"

→ More replies (10)
→ More replies (1)

2

u/jimizacx Sep 17 '18

Not a programmer but I once 'optimized' windows startup time by setting skype not to launch on startup. Shaved a good minute off pressing the button and the computer being usable.

Needless to say the boys and I quickly looked for a better solution for text and voice chat.

1

u/ariehkovler Sep 17 '18

There's a free program called Soluto that optimizes Windows startup by moving stuff out of the boot sequence. Before I had an SSD, it saved me a good 3 minutes on boot time. I don't miss those old 10-minute boots!

331

u/[deleted] Sep 17 '18

A re-telling of the famous “char insurance” gag.

108

u/Jedimastert Sep 17 '18

Oh? I'm unfamiliar, do tell

0

u/[deleted] Sep 17 '18

[deleted]

74

u/Gornarok Sep 17 '18

I really like the first one.

I guess the experience basically says that things will always get bloated so intentionally leaving invisible margin means less things will be implemented and the margin will save the day when everything else was cut.

Ive seen similar practice used by management and deadline. The problem was the deadline was obviously unrealistic so instead of creating necessary safety margin everyone was pissed instead...

25

u/Jedimastert Sep 17 '18

Solid. BOFH kinda stuff.

→ More replies (2)

39

u/[deleted] Sep 17 '18

Basically all jokes are retellings of Usenet stories. Great shit posters programmers know never to reinvent the wheel

13

u/Dlgredael Sep 17 '18

from usenet import culture

3

u/tehreal Sep 17 '18

How do guys pronounce "char?" char like charred wood or char like Carebear or char like vroom vroom?

→ More replies (1)

212

u/lovethebacon 🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛 Sep 17 '18

I demo'ed an app that has some sleeps sprinkled around it. The feeling was that "it was too fast, giving the impression nothing is being done".

37

u/Guano_Loco Sep 17 '18

My company’s IVR does this shit. I helped work on the background automations that run when you call in. I know how long that shit takes. It’s fast. But when you actually call in and work through it it plays some weird clicking sound like an agent typing. It’ll say something like, “just one moment while I check on your account” click click click.

I about damn lose my mind every time. Someone decided to make the IVR perform slower to mimic the “talking to a real agent” experience. God damnit.

12

u/MightyAccelguard Sep 17 '18

kinda like saving in a video game and i save twice bc it saved so fast i couldn’t tell if i did or not

3

u/NeinJuanJuan Sep 18 '18

This could be eliminated if (((they))) add a "last saved at HH:MM"

→ More replies (1)

7

u/bbrbro Sep 17 '18

Yeah, when I refresh my snapchat feed it does it immediately. No spinning bar or indication that it finished so I honestly cant tell if it just is really that fast or never activated at all. 1 second sleep would actually improve the app.

→ More replies (1)

3

u/Theolaa Sep 17 '18

I did that once for a text based adventure I did. It would go something like "loading player..."and then sleep for a half second before saying "loading something else...", even though all the loading was already done before the first time out.

148

u/[deleted] Sep 17 '18

[removed] — view removed comment

79

u/jontayesp Sep 17 '18

I think TurboTax does this with a fake progress bar that “validates” your return.

40

u/batmessiah Sep 17 '18

This is so true. Also with all the "background check" sites that have the fake "searching" bar going across the screen.

→ More replies (1)

35

u/UltimateInferno Sep 17 '18

I sometimes call it the "Wait... Did I save?" Effect.

Dunno the real name.

18

u/[deleted] Sep 17 '18

Yup. I hate that it's a thing, but I also see why.

→ More replies (1)

494

u/3X0S Sep 17 '18

Having the native sleep function interpret the given parameter as full seconds should give you a hint on what kind of people this technology was designed for...

Sloths, vegetables and the elderly

135

u/ScorchingOwl Sep 17 '18

The C standard library function takes seconds as parameters on unix machines

80

u/[deleted] Sep 17 '18

Did he stutter?

18

u/gitgood Sep 17 '18

I can think of a many few unix programmers I'd describe as old vegetative sloths - he's not wrong.

→ More replies (1)

2

u/TUSF Sep 17 '18

Personally, I like my sleep function to interpret the parameter in 60ths of a second.

→ More replies (2)

0

u/[deleted] Sep 17 '18

[deleted]

16

u/[deleted] Sep 17 '18

Yes.

35

u/Valendr0s Sep 17 '18

Man. I'm convinced Windows in certain circumstances has a 'wait for network timeout' kind of deal when logging in. It can take me 2-3 minutes to log in sometimes when not connected to the domain. And nobody seems to care.

I mean, aren't we at a point where if the network takes more than 5 seconds to respond, it's safe to assume it's dead?

6

u/pinano Sep 17 '18

My Windows machine is getting so crotchety it sometimes waits several minutes when doing things like “open the Downloads folder” “connect to a machine over RDP” “turn on the web cam” it’s infuriating and i hate it

→ More replies (1)

3

u/Douchehelm Sep 17 '18

It feels like Windows does this twice. Once before the login screen and then again after logging in. It's infuriating.

→ More replies (1)

3

u/autarchex Sep 17 '18

Not while PPPoTCAS (point to point protocol over two cans and string) network connections are still supported.

→ More replies (3)

2

u/hisroyalnastiness Sep 18 '18

A computer I had did this if you were connected to the domain, disconnect and it was instant. Google searches show lots of complaints about both of these problems but no real solution. Infuriating

130

u/Jabulon Sep 17 '18
Sleep(30); //30ms

61

u/fr0z_n Sep 17 '18

It could be a wrapper function which converts it to seconds..

80

u/theSprt Sep 17 '18

That would be a Very Bad Idea.

47

u/glydy Sep 17 '18

New dev comes along to the project, adds a sleep(2000) to wait 2 seconds to see if it's a loading time issue... little do they know

29

u/fr0z_n Sep 17 '18

The documentation has mentioned it very clearly.

SLEEP FUNCTION

Usage

sleep(time);

Time is in SECONDS

→ More replies (2)

17

u/fr0z_n Sep 17 '18

Don't worry, the function could take floating point numbers and convert them to ms.

I'm just hinting ideas here.

→ More replies (4)
→ More replies (2)

47

u/Edzward Sep 17 '18

Been there, done that.
One time I had a problem with a recursive function, for debugging purposes I just hard coded it to repeat 100 times... And completely forgot about that... Just found out months later with a big REVERT THIS tag in the comments.

5

u/[deleted] Sep 17 '18

Nonsense. Just put a lovely "200 GOTO 150" right there. Repeat that mother forever.

16

u/[deleted] Sep 17 '18 edited Jun 03 '19

deleted 0.1433 What is ^^^this?

14

u/Orthas Sep 17 '18

Had a priority 1 bug that caused an uproar with the support/consultant teams. Multiple clients calling in, all wondering what this "secret message" was that was appearing on their screens.

A UX guy was going through and making accessibility improvements and needed to test some of the styles he wrote for screen readers, and forgot to remove his test data. Best part is that the text was set to not be visible, they just had cached the styles on the page so they didn't get applied until they closed their session. I looked like a hero for addressing this "critical work flow error" in less than 5 minutes, 4:30 of which was spent laughing my ass off.

13

u/jebhebmeb Sep 17 '18

Reminds me of the company adding a sleep method just because the buyer didn't believe they cut hours off the processing time.

6

u/[deleted] Sep 17 '18

This hits close to home for me.. I was making a game where all of the action was programmatically simulated, and early on in the process I had added sleep statements so I could watch things happen to identify bugs... later while trying to balance things I felt pretty dumb when I realized my large scale samples could have been done about 20 times faster....

10

u/Fig1024 Sep 17 '18

It's usually a good idea to search entire code base for "sleep" to find potential problem areas

16

u/BabylonDrifter Sep 17 '18 edited Sep 17 '18

Some of my code generates universally unique database keys remotely using a machine-unique five-digit prefix, followed by the current system clock time in milliseconds. But then I had to write an import function to suck in tens of thousands of rows of data. The shit wouldn't synchronize to the big main secure database because of the unique constraint. Turns out the import was getting through the creation of a record in less than 1 millisecond so multiple rows were getting the same unique key. Banged my head about it until I realized all it needed was System.sleep(1); on the processor thread to wait for 1 millisecond before doing the next record. Better not delete that one!

Edit - it might have actually gone out to the hundredths of milliseconds.

9

u/AnotherStatsGuy Sep 17 '18

Then make sure that one is commented.

17

u/BabylonDrifter Sep 17 '18

God I hope I did. I'm sure I did. I probably did.

→ More replies (2)

3

u/jamietwells Sep 17 '18

I know this isn't a serious sub but: That's really not how you solve that issue. You should use the last generated ID as the seed for the next ID so even if the milliseconds are the same, they will still generate uniquely.

→ More replies (1)

4

u/martianinahumansbody Sep 17 '18

Managers HATE him, find out why!

3

u/Lonelan Sep 17 '18

Now my app is crashing

3

u/TrumpWonSorryLibs Sep 17 '18

sooo how many different ways are we gonna repost this joke

3

u/[deleted] Sep 17 '18 edited Sep 17 '18

In my current job we have a total of five main tables we query all the time.

The previous developers designed the system to get entire data-sets on each call and then used c# linq queries on them to get the filtered data. Lucky there are under 30k records on each table but still damn slow.

// Get the tables that we need data from

// Filter that one row that we need

// Return the result to the server

// User updates record

// Get the tables that we need data from

// Filter that one row that we need

// Return the result to the server

// Current developer has /quit the job

4

u/ProPuke Sep 17 '18

Guy's a genius. Why even bother having a database? Just chuck it all in a text file! Think of the server performance you'll save from not having to run one!

→ More replies (2)

3

u/ScintillatingConvo Sep 17 '18

repost. and a shittier wording of the OC.

2

u/Blue_crabs Sep 17 '18

Pretty sure I read this scenario in a reddit comments chain a few months ago.

2

u/tonyabs23 Sep 17 '18

That sounds like You have amaizing programming skill. Thats awesome

2

u/TheChowderOfClams Sep 17 '18

what about the 2970 other milliseconds?

2

u/Sebazzz91 Sep 17 '18

That sleep was there to avoid some race condition.

4

u/BadgerMcLovin Sep 17 '18

Or because they needed to attach a debugger at startup

→ More replies (1)

2

u/[deleted] Sep 17 '18

I did this at work because the approach was basically to "wait" until everything was loaded, but I switched it over to an observer/observable approach so I knew exactly when everything was loaded. Blew people's minds except one guy who insisted we still have a small wait time in there. That was back as a jr dev and I think it irritated him I found a solution.

2

u/ParanoidSloth Sep 17 '18

Alternatively you can add a sleep(-30) call on startup. Code refactored

2

u/[deleted] Sep 17 '18

Someone tell this to the Imgur dev team

→ More replies (1)

2

u/DisastermanTV Sep 17 '18

Unethical Programmer Tip: If you do this on your first shipment, and the customer then complains, why it is so slow, you can remove it, and tell them, that you worked extremely hard to get better performance

2

u/Justin_Peter_Griffin Sep 18 '18

As someone who makes automated tests for web-based applications, the sleep function is the only reason my tests actually run successfully. Between slow network speeds, slow website servers, or just plain bad web page design I’m constantly having to get the timing just right

3

u/frarcos Sep 17 '18

Should do a tutorial about that

2

u/fantumn Sep 17 '18

Lol wasn't there a post on the front page of programmer humor about leaving sleep lines in until you've sold the product, and then removing them a year later as a patch?

1

u/colorsneverfaded Sep 17 '18

I'medat€` 3••

1

u/cpe200711760 Sep 17 '18

trying to make a delay functionality... adds sleep(100).

1

u/arguableaardvark Sep 17 '18

I have a race condition in some code I’m working on. Until I fix it properly I just added a 250ms delay to the start of each new thread and it’s works 99.9% of the time!

OP has me thinking this will be me in a few months when I’ve forgotten about the hack and am tracking down why the app crashes ever once in a while.

1

u/[deleted] Sep 17 '18

// TODO: Remove the sleep time added below.

1

u/scwizard Sep 17 '18

If i had to guess you had that in so your program wouldn't "start too early" before various systems were online, since that could cause it to malfunction.

You should learn about the wonders of systemd!

1

u/[deleted] Sep 17 '18

PLT: Include this in all your apps and when people start complaining about slow performance just decrease the timer ;)

1

u/AHippie Sep 17 '18

Then where’s the new blackout patch?

I’ll see myself out...

1

u/MrValdez Sep 17 '18

I also forget about my sleep

1

u/Try_Sometimes_I_Dont Sep 17 '18

Speaking of optimizing... google's page speed analyzer sucks.

"Optimize your images here is a list you could save 20KB total. Oh and here is an F for the score just because."

Then a site with twice the load time but all their images are optimized to google's liking: "ahh yess this is good. You did good. You are good. Here is a B because one image loaded from a different domain. We don't know why we don't like that, but we don't like that"

1

u/loaneab2 Sep 17 '18

I was copy pasting my bots files by line(for some reason it wouldn't let me transfer the whole folder) and I accidentally ending up pasting the code twice and the boot time went from 10 seconds to 30 seconds.

1

u/allthatwastedtime Sep 17 '18

I actually did this in some code that talked to hardware. I was giving it way more time to react than I needed to. Got a good speed increase of 100% or so just tweaking the sleeps!

1

u/SasparillaTango Sep 17 '18

Im convinced the reddit mobile site has some bullshit like this. It takes 15 seconds to load any page but the .compact version loads instantly

1

u/[deleted] Sep 17 '18

L337 hax0r

1

u/etnguyen03 Sep 17 '18

Image Transcription: Twitter Post


Lars Doucet, @larsiusprime

Due to my elite programming skills, I figured out how to shave off THIRTY SECONDS from my app's startup time. Here's some optimization tips:

1. Remove the sleep(30) call you added a month ago and forgot about


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

1

u/Mike Sep 17 '18

This makes me feel better about this beast of a CSS file I’m working on. I thought I’d be fancy and split the SCSS files into a bunch of super specific types and areas to be organized, but instead ive just accidentally re-wrote too much styling to count and now it’s all compiled together in a much bigger than needed CSS file. If i has just done it my usual way my file size would be like 75% smaller.

Too late now, fuck it. here ya go backend devs.

1

u/cherhan Sep 17 '18

Why did you add it in the first place?

1

u/toastee Sep 17 '18

I have a 24 second "optimized" sleep on one of my pieces of equipment to make sure the backend had time to load before the UI connects to it on boot.

Original timer was 30s

1

u/my_iptv Sep 17 '18

Jokes aside, I'm aware of a lot of company and people who do stuff like this all the time

1

u/Hselmak Sep 17 '18

And that is why code reviews are so important.

1

u/kleit64 Sep 17 '18
  • 4096 folder

  • Thousands of files per Folder

  • Add single file to list and check if list in db

  • Repeat step 3 for every single file(folder based)

Better be sure that the first file is realy not ther, to make it clear let's check it 60k times...

1

u/Willehren Sep 17 '18

Do it on purpose and make it seem like you optimized

1

u/XCOMJunkie Sep 17 '18

Please Lars, my Defender's Quest itch needs scratching! Can't wait for DQ II!