The most upvoted question in the history of StackOverflow(stackoverflow.com)
stackoverflow.com
The most upvoted question in the history of StackOverflow
https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array
13 comments
I thought for sure it was going to be "How do I exit vim?"
I was expecting this post, asking the best ways to match HTML tags with regular expressions.
https://stackoverflow.com/questions/1732348/regex-match-open...
Sadly the page is currently locked, likely as a conspiracy to avoid it overtaking the OP.
https://stackoverflow.com/questions/1732348/regex-match-open...
Sadly the page is currently locked, likely as a conspiracy to avoid it overtaking the OP.
It’s locked so you can’t edit it, but you can still upvote it if you want.
I know it is a joke, but: It "Only" has 4867 votes while the answer has 5947. This seems to be the highest voted "How do I exit vim?" Post.
https://stackoverflow.com/questions/11828270/how-do-i-exit-v...
It is a perfect example of why you need to know the low level gritty details of how modern CPU’s (and Caches/RAM) works to write high performance high level code. A few years ago I optimised a C++ constraint algorithm from 47 minutes to 2 secs by re-arranging how the data access was organised. Writing your code in C++ doesn’t automatically make it fast. You still need to understand the low level details to make fast code.
Summary: due to deep pipelines and branch prediction, a tight loop with a single if statement goes fastest if the test nearly always comes out the same way as last time, and slowest when it is true or false at random.
I'd always been suspicious of all the black magic optimization that my compiler/library implementation/runtime did discreetly behind the hood.
My take away from this question and and the top answer was that the above is not true. It does not mean that everyone has to code using assembly - it means that good programmers are aware of where their abstractions may leak.
Related reading (can't believe it's almost 20 years since this article was written) - https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-a...