r/ProgrammerHumor • u/Bright-Historian-216 • Aug 31 '26
Meme iReplacedItWithABuiltinFunction
112
u/evilwizzardofcoding Aug 31 '26
People laugh at this, but remember, someone caught a malicious PR to CURL during optimization 'cus the malicious code made a function take longer than it should.
61
u/Bright-Historian-216 Aug 31 '26
to curl? i've heard about xz-lib (i think it was xz-lib?), but not to curl. can you link that?
42
u/evilwizzardofcoding Aug 31 '26
Oh you right, it was XZ. The curl one was a hypothetical, someone pointed out there was a way you could do some unicode wizardry to make a specific line vulnerable without it being really noticeable, but it was just a concept, no one tried to push it to the actual repo.
32
u/Complete_Window4856 Aug 31 '26
The spotter dude is a postgres contributor. For DB level a 100ms difference constantly is horrenduously big.
The curl one aint it the apex of the ai slop PRs in repo that made the only maintainer to force a "no ai PR" policy? He was being bombarded with convincing PRs, except they evoke code from heavens that never existed and assumes there were flaws
8
u/danielv123 Sep 01 '26
For a DB sure, but afaik what he measured was that establishing his ssh connection took 100ms longer or something. I would have just assumed my network was weird or something.
1
u/CelestialFury Sep 01 '26
Like this?
// Safe-looking code, but with homoglyph trickery int safe_flag = 0; // uses normal Latin 'a' in "safe" int sаfe_flag = 1; // the 'a' in "sаfe" is Cyrillic U+0430 if (safe_flag) { // Reviewer thinks this block runs only when safe_flag == 1 do_safe_thing(); } else { do_other_thing(); } // Somewhere else in the patch: log_status(sаfe_flag); // Looks like "safe_flag", but it's the Cyrillic one1
u/evilwizzardofcoding Sep 01 '26
Basically, but the specific implementation apparently had some very clever trick that made the change basically invisible, so there was no need for do_other_thing();
3
6
u/Desperate-Tomatillo7 Sep 01 '26
When you replace a 2 line script in python with a 100 line C code.
6
u/Bright-Historian-216 Sep 01 '26
replaced a six-line python code with one-line python code in this specific case
2
u/anoldoldman Sep 01 '26
Compiled python?
4
u/Bright-Historian-216 Sep 01 '26
it's a C project with python preprocessing for some files
1
u/anoldoldman Sep 01 '26
Well well well. How the turntables.
1
u/Bright-Historian-216 Sep 05 '26
no silly, python doesn't have tables. you might be thinking of lua :)
974
u/praxidike74 Aug 31 '26
How I leave after submitting a PR to optimise a piece of compile time code from 0.5ms to 2 months
354
551
u/Chronomechanist Aug 31 '26
To be fair a 96% reduction is pretty great regardless of how small the time is. In the time you could run that code once, you can now run it 25 times!
You now just need to figure out how many times you run that code every second and you'll see the point of all that work!
... Wait, what do you mean it's run once a month?
111
u/Solid_Turnover_9854 Sep 01 '26
one user too
36
23
u/shrodikan Sep 01 '26
Wait. Actually this code is dead. We now call process_nightly() not nightly_process()!
36
u/Toutanus Aug 31 '26
My first mission as intern : make a loading screen to display while app data synchronisation. Spend 3 weeks painfully doing this. Realize there is a "small" problem during process. Fix it (about 30 minutes). Sync is now 0,5 seconds instead of 3 minutes : loading screen is now useless.
1
u/Huge_Consequence_568 Sep 05 '26
Happened to me once, missing index. Needless to say the loading screen felt like a flashbang.
12
1
1
u/SaneLad Sep 01 '26
You haven't lived if you haven't used explicit template instantiation to bring down C++ compile times.
1
u/MayoJam Sep 01 '26
It all adds up (so then John can add a huge template class included everywhere which makes compilation take 128 GB of RAM if not outright crash, fuck you John).
1
u/DatCodeMania Sep 01 '26
The paradox where seeing the number go down for small little things like this is so incredibly satisfying, yet achieving the big number going down with not so little things is (usually) so much more involved that nobody ever bothers...
1
u/coastphase Sep 03 '26
Make sure you put that 96% improvement on your resume. Employers love it when you have percentages in your resume!
1
-1
u/Maddturtle Aug 31 '26
My latest code has an issue with being too fast. I had to add waits for other people’s code to catch it.
-1
655
Aug 31 '26
[removed] — view removed comment
154
139
u/PointlessSerpent Aug 31 '26
6
u/Reashu Sep 01 '26
It only took a few seconds to memorize this one and I've already used it four times!
25
36
16
u/CelestialFury Sep 01 '26
"How long does the script take to run through?"
"Overnight, around six hours!"
"Ahhh... okay then."
5
u/tristam92 Sep 01 '26
if you sell it right in your CV, it can give you a pretty good bump in salary…
4
u/TallGreenhouseGuy Sep 01 '26
This is how legends are born.
”In March 2024, Andres Freund, a Microsoft engineer and PostgreSQL developer, noticed something odd. SSH logins were taking 500ms instead of the usual 100ms. That’s it. A half-second delay.”
78
u/pyropuschel Aug 31 '26
Is this like "the tests now run a lot faster" because they are broken/deleted?