> O(n^2) is the sweet spot of badly scaling algorithms: fast enough to make it into production, but slow enough to make things fall down once it gets there.
https://randomascii.wordpress.com/2021/02/16/arranging-invis...
How I cut GTA Online loading times by 70% https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times...
For something mission critical like a bootloader that's more valuable than turning O(n^2) into O(n log n). People running systems like BSD largely don't care how long the system takes to boot, once it's booted the system runs for years.
it doesn't seem mentioned in the HN thread the cause here is probably the same thing O(n^2): sorting. laying out icons is only linear if the icons are read in the order that they're placed. It's been a long time since I used windows regularly but my memory is the default placement is by creation time. So if they're read off disk by filename (or some sort of hash) they'd need to be sorted by timestamp.
https://twitter.com/cperciva/status/1659391725427720195?t=0y...
also why cant freaking boot process be optimized after first boot? bsd is essentialy sorting SAME thing every boot, THAT is ridiculous. sort once, save order ( list, sysinit000000000000 ), boot fast next time. hardware or other change or failed boot, can trigger start sorting bull for safety.
you know what youre booting into, so sort it once then run it from saved order next time. how many times you change hardware on computer ? and if you do, you can just restart with grub flag, toggle switch in control panel before restart, etc
I'd consider this less "haha dum code is slow" and more "you are booting the kernel way too much, even a 1.97 millisecond delay is noticable".
Of course, calling anything that takes place in less than a blink of an eye "slow" is overstating things... lol :-)
If only I could get my desktop environment to come up in less than 28ms :-)
My tv boots a kernel, Alexa's, laptops, cars etc.
And this might be not specifically critical but it's a sign of people just doing something less optimal
Why do we even need to waste any consciousness-seconds on watching electric circuits initialize? Computers should just start working
That is, until someone searches for e.g. git conflict markers.
At a glance looks like 13.1-RELEASE booted 3x faster than 11.1-RELEASE, and 14.0-CURRENT on Firecracker boots 45x faster than 11.1-RELEASE on a c5.xlarge
Outside of toy projects, interviews, and teaching them, I've never actually written a sort function. I never saw the point; the sort function built into the standard library of whatever language I'm using is probably faster and/or more space efficient than whatever thing I whip up in a few seconds.
Of course, that's a privileged opinion that I am afforded by the fact that my entire career has been "Java and higher" languages.
... downthread ...
> I suspect quicksort will be enough though.
Somebody hasn't taken a freshman complexity theory class in a while...
(Note, this is tongue in cheek. Worst case is not average case and all that. I'm sure quicksort will do fine)
My trick was stupid simple. The usual file I/O buffer size was 512 bytes, I made it 16K.
CONNECTION *c = malloc(num_nodes * num_nodes * sizeof(CONNECT_STRUCT));
And almost the entire matrix was empty because most things in a network aren't connected to each other. I spent a a few minutes replacing that with a hash table on the (i, j) node pair.Both C++ and Rust have pretty nice sorting algorithms in the standard library. C does not (qsort doesn’t really count as a nice sorting algorithm which is why so many C programmers took their own).
If I'm understanding correctly, we're talking about sorting integers. Would something like radix sort not be more appropriate? Or is there a reason to still prefer a more generic sorting algorithm?
https://twitter.com/cperciva/status/1659577625289928705
So this bubble sort is just under 2ms.
I think it's cool to find and optimize that, he says he'll put in a qsort and that's great. But 2ms? Probably not a huge deal.
-somebody who accepted a bet
"The kernel boot (of which 7% is bubblesort) is 28 ms."