HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Sorting Algorithms: Speed Is Found In The Minds of People - Andrei Alexandrescu - CppCon 2019

CppCon · Youtube · 25 HN points · 9 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention CppCon's video "Sorting Algorithms: Speed Is Found In The Minds of People - Andrei Alexandrescu - CppCon 2019".
Youtube Summary
http://CppCon.org
Discussion & Comments: https://www.reddit.com/r/cpp/
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2019

Sorting Algorithms: Speed Is Found In The Minds of People

In all likelihood, sorting is one of the most researched classes of algorithms. It is a fundamental task in Computer Science, both on its own and as a step in other algorithms. Efficient algorithms for sorting and searching are now taught in core undergraduate classes. Are they at their best, or is there more blood to squeeze from that stone? This talk will explore a few less known – but more allegro! – variants of classic sorting algorithms. And as they say, the road matters more than the destination. Along the way, we'll encounter many wondrous surprises and we'll learn how to cope with the puzzling behavior of modern complex architectures.

Andrei Alexandrescu

Andrei Alexandrescu is a researcher, software engineer, and author. He wrote three best-selling books on programming (Modern C++ Design, C++ Coding Standards, and The D Programming Language) and numerous articles and papers on wide-ranging topics from programming to language design to Machine Learning to Natural Language Processing. Andrei holds a PhD in Computer Science from the University of Washington and a BSc in Electrical Engineering from University "Politehnica" Bucharest. He is the Vice President of the D Language Foundation.

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

*-----*
The CppCon YouTube Channel Is Sponsored By:
SonarSource: https://www.sonarsource.com/
*-----*
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Feb 12, 2022 · 2 points, 0 comments · submitted by jbp
This is a thing, see https://www.youtube.com/watch?v=FJJTYQYB1JQ (talk by Andrei Alexandrescu at CppCon 2019 about this exact idea)
jiggawatts
Upvoted because this is a fantastic talk all by itself, and also highly topical.
ncmncm
As I recall, this was the talk that triggered me to begin the experiments that led to the article.
Andrei has a pretty amazing CppCon talk similar to this: https://youtu.be/FJJTYQYB1JQ
Do you have some more detaile about your app?

I use perf, sysprof, trace32, visual studio profiler for profiling, but this highly depends on your environment.

These assorted links might be interesting to you:

- https://github.com/Kobzol/hardware-effects

- https://www.youtube.com/watch?v=FJJTYQYB1JQ

- https://godbolt.org/

- http://igoro.com/archive/gallery-of-processor-cache-effects/

I'm not sure about much analysis and theory that explicitly captures branch prediction, but in last year's cppcon keynote Andrei offered a possible metric [0] where he takes into account the average "distance" between two subsequent array accesses.

It's basically, (C(n) + M(n) + kD(n)) / n

Where M is moves, C is comparisons, k is a some constant, and D is "distance".

[0]: https://youtu.be/FJJTYQYB1JQ?t=2943

Well, this argument goes both ways, a generic implementation can never leverage special properties of your data. See i.e. Alexandrecu's talk [0] at about 1:05ff. If as a company you have special use cases or guidelines, you may easily benefit from libraries using these properties.

[0] https://youtu.be/FJJTYQYB1JQ

I enjoyed Alexandrescu’s CppCon 2019 talk “Speed Is Found In The Minds of People”

About optimizing generic sorting routines for modern hardware.

https://www.youtube.com/watch?v=FJJTYQYB1JQ

In his talk "Speed Is Found In The Minds of People" [0], Andrei Alexandrescu tries to make a sort really fast for medium sized vector and then closes on thoughts on this precise distinction.

If this question intress you, it is worth watching.

[0]: https://youtu.be/FJJTYQYB1JQ

The article is C++, so not sure why you are bringing up AOT/JIT since it doesn't apply here. And clearly there is a large gain possible by doing a calculation rather than a conditional with a high entropy result, otherwise, the article's mentioned speedup wouldn't have happened. A PGO feedback loop isn't going to do anything on a high entropy conditional. I saw a great talk at CppCon 2019 by Andrei Alexandrescu about speeding up std::sort. He does this same trick among others to speed up the C++ std library sort routine.

https://www.youtube.com/watch?v=FJJTYQYB1JQ

pjmlp
Because implementation and programming language are not the same thing?

Speaking of which, better catch up on the C++ interpreters and JIT related talks from CppCon 2019.

planteen
I can't tell if you are trying to troll here. So you reject the notion of branchless coding as a premature optimization because you think it is going to be made irrelevant by a potential future microcode update? Or are you saying that a C++ interpreter/JIT would have made this branchless at run-time, but that optimization isn't made at compile time?
pjmlp
The first one naturally.

The tone of my previous remark is that optimization algorithms are orthogonal to programming languages, an language agnostic backend optimizer working on AST and SSA passes doesn't care what the input language was all about.

If you're interested in these types of implementation/optimization details, Andrei Alexandrescu gave a great talk at this year's CppCon about practical sorting, e.g. when to break out of quicksort to something else: https://www.youtube.com/watch?v=FJJTYQYB1JQ
drudru11
Thanks for this recommendation. It pushed me to finally watch it and I found it to be a really nice talk.
Sep 22, 2019 · 1 points, 0 comments · submitted by agumonkey
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.