CppCon 2017: Nicholas Ormrod “Fantastic Algorithms and Where To Find Them”

  Рет қаралды 62,440

CppCon

CppCon

6 жыл бұрын

Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
-
Come dive into some exciting algorithms - tools rare enough to be novel, but useful enough to be found in practice. Want to learn about "heavy hitters" to prevent DOS attacks? Come to this talk. Want to avoid smashing your stack during tree destruction? Come to this talk. Want to hear war stories about how a new algorithm saved the day? Come to this talk! We'll dive into the finest of algorithms and see them in use - Fantastic Algorithms, and Where To Find Them.
-
Nicholas Ormrod: Facebook, Software Engineer
Nicholas is a infrastructure engineer at Facebook. If he talks too much, disable him with a well-placed nerd snipe.
-
Videos Filmed & Edited by Bash Films: www.BashFilms.com
*-----*
Register Now For CppCon 2022: cppcon.org/registration/
*-----*

Пікірлер: 49
@aaakashkumar
@aaakashkumar 3 жыл бұрын
1:22 Heavy Hitters 11:42 Morris Traversal 20:40 Reservoir Sampling 27:32 HyperLogLog
@DareToSavorVanillaWithBacon
@DareToSavorVanillaWithBacon 5 жыл бұрын
Feels like a TED talk
@mohammedj2941
@mohammedj2941 3 жыл бұрын
A compliment or criticism?
@blazkowicz666
@blazkowicz666 2 жыл бұрын
@@mohammedj2941 yes
@tophyr
@tophyr 5 жыл бұрын
JFC some of you guys are a tough audience. This is a great presentation, with not a single "um" - what you're picking up on as conceitedness or actor-ness or whatever the hell else is "wrong" with the way he talks is simply a well-rehearsed talk and emotive vocal tones so that the audience doesn't fall asleep in the middle of some dense technical material.
@philipfry9436
@philipfry9436 4 жыл бұрын
21:50 And that is why Facebook's 'biggrep' is so fast. It bail out when it get too slow.
@abhalla
@abhalla Ай бұрын
Excellent talk, both in terms of content and delivery. Thank you.
@Dominik-K
@Dominik-K Жыл бұрын
This is a really amazing talk and it's true, that algorithms are the tools of our trade
@bstlang
@bstlang 6 жыл бұрын
For binary tree destruction Morris Traversal is overkill, given that you don't need to reconstruct the original structure of the tree. A Θ(N) speed algorithm with O(1) space requirement follows, with the added benefit of being very small, thus not putting much pressure on the instruction cache: while (root) { while (root->left) { root = root->rotate_right(); } auto next = root->right; delete root; root = next; } O(N) rotations will be performed as well as Θ(N) deletions. This is essentially: singly_linked_list_destroy(binary_tree_to_slist(root));
@peppybocan
@peppybocan 6 жыл бұрын
but pointers are BAAAAD :D ... but recursion is uuuglyyy... :D ... sometimes I feel like language PROs are in the C++ STD Committee and everyone else is just a noob from kindergarten.
@CrimsonTide001
@CrimsonTide001 6 жыл бұрын
That's what I was originally thinking he was going to do.
@multigladiator384
@multigladiator384 5 жыл бұрын
this is a good solution sir
@absurdengineering
@absurdengineering 3 жыл бұрын
I urge you to write out rotate_right. It’s not free, it’s not O(1).
@gregkrimer1000
@gregkrimer1000 2 жыл бұрын
Brilliant presentation
@rakesh4a1
@rakesh4a1 6 жыл бұрын
This is very very gud presentation on algorithms, i saw his other talks too. I do not have that level of understanding of algorithms, has to try understanding these.
@GeorgeTsiros
@GeorgeTsiros 5 жыл бұрын
"uhm"s per minute: 0 !
@nathanssteurs1650
@nathanssteurs1650 6 жыл бұрын
Great talk, but who says "unique putter"
@brothir
@brothir 6 жыл бұрын
Unfortunately it's not uncommon I find. I hardly ever abbreviate anything, but if I were to abbreviate pointer it'd be "pntr". People would still probably say something like "punter", but what can you do.
@noxabellus
@noxabellus 6 жыл бұрын
Group-think gurus and their followers
@bartekkko
@bartekkko 6 жыл бұрын
Because in the STL it's called unique_ptr
@kim15742
@kim15742 5 жыл бұрын
Herb Sutter for example, Scott Meyers
@fdwr
@fdwr 5 жыл бұрын
Nod, it sounds ridiculous. Is it any harder to say the correct word "pointer"?..
@prydt
@prydt 2 жыл бұрын
loved the talk!
@Peregringlk
@Peregringlk 5 ай бұрын
In 31:42, it says the probability of having K leading zeros is 1/2^k. So, the probability of having no leading zeros (the first bit is 1), is 1. Which means that you are granted that any random string have no zeros at the beginning, which is not true. I think 1/2^k is the probability of having k leading equal bits: k zeros, or k ones. If you want to restrict to be specifically k zeros, I think the probability will be 1/2^(k+1). Right? So there's a 50% probability of having a bit string with 0 leading zeros, which matches his next sentences of saying that 64 numbers (out of 128) will have no leading zeros.
@intvnut
@intvnut 6 жыл бұрын
So, is 1 -> 2 -> 6 a Prisoner reference buried in this? Or is that a coincidence?
@majohime
@majohime Жыл бұрын
Didn't quite understand Morris Traversal in terms of tree destroying. No example of how actually apply this to real tree of unique_ptr-s, I heard speaker mention that in -O1 and higher compilers already do similar thing to optimize destruction but so what? I should just hope my future code will be optimized or I can actually perform this traversal and somehow do this destruction without ever touching raw pointers and doing everything with unique_ptr? Should I call something like right.~Node() while traversing or what?
@OperationDarkside
@OperationDarkside 6 жыл бұрын
Love this way of presentation. Didn't get everything though. But good to know where to find all of that.
@DarkTrunksGeorgeSim
@DarkTrunksGeorgeSim 6 жыл бұрын
Didn't he mean necessary but not sufficient at ~8:00?
@alcesmir
@alcesmir 5 жыл бұрын
Very much so.
@mohammedj2941
@mohammedj2941 3 жыл бұрын
I came to the comment section just to search for this.
@houdiniping
@houdiniping 16 күн бұрын
so where to find these algorithms origin?
@shivkrishnajaiswal8394
@shivkrishnajaiswal8394 7 ай бұрын
Wow!!
@4olovik
@4olovik 6 жыл бұрын
excellent
@nrwchd
@nrwchd Жыл бұрын
whoa his parent really named his son orgmode. what a hard core emacs user.
@arisweedler4703
@arisweedler4703 2 жыл бұрын
VANLOON’s talk: kzbin.info/www/bejne/m5rHdnijfLGEmbc
@Cromius771
@Cromius771 6 жыл бұрын
He should have used std::random instead of his random() % k. He has no idea what type of distribution hes dealing with.
@tobiasfuchs7016
@tobiasfuchs7016 6 жыл бұрын
Absolutely, but his point is the algorithm. Picking a suitable distribution is left as an exercise.
@hansiraber
@hansiraber 6 жыл бұрын
it seems the algorithm requires uniform distribution. but it should be fine, because that's what the hash function will produce.
@TomaszWiszkowski
@TomaszWiszkowski 6 жыл бұрын
This all looks great until you realize what happens when things go a tiny bit wrong. Not wrong as a whole. Just a tiny bit. Off-by-one error. If you consider stack overflow as a reason for your code crash - you should very well consider how you would diagnose a single element memory leak in your tree deletion - or use after delete, because whoever wrote that cleverness actually made a typo resulting in a warning reported by tools 3 months later. The algorithm for heavy hitters made me wonder what would happen if the order was A - B - A - B - C - C. There's no heavy hitter here, yet the algorithm says it's C. I'd hate to debug this. I love the unconventional approach to the problem, but with code complexity we're hitting with C++ these days I think I would prefer to have my code readable as a priority. A little bit of pressure on stack is not so much of a trouble. if your trees are poorly balanced you have a much bigger problem than stack use during destruction: it's very likely going to hit your performance. In general. Now picture this (not unheard-of) scenario: your team inherited a project with some technological debt from overseas. The project conceptually is simple, but it's full of quirks like that. You get your stash of bugs along with the source code. What do you do next? Well, you spend next two months learning what the heck is going on - and everything looks like a potential bug. It doesn't have to be, but it just looks like that. A cycle in a binary tree, for example.
@MonsterCutter
@MonsterCutter 6 жыл бұрын
Or even A - B - A - B - A - B -B - C - C. There B is the heavy hitter but the algo chooses C (which is of the least occurrence). That's probably why he says you need to go through it once again to verify. However I'm wondering how practical it is to go through all the requests since the beginning of Facebook just to verify a heavy hitter (that can still take some considerable amount of time and that on every request, since you want O(1) space thus cannot store anything else than the current hitter? - and for the second pass you need to store the requests somewhere anyway to go through them again, so you're back to O(N) space). And then you went through all the requests since the beginning of time just to find out your algo failed to choose the heavy hitter, and then what?
@Voy2378
@Voy2378 6 жыл бұрын
You did not understand this lecture. Algorithm does the second pass, algorithm is fine.
@ruroruro
@ruroruro 5 жыл бұрын
@@MonsterCutter Hello from 2019. You probably don't remember or care about this, buuuut. In your example, there is no Heavy Hitter. There are 4 Bs out of 9 elements, which is less than majority (50%). Also, he mentions, both the time and second pass concerns. I've actually been researching the problem in question a bit and it seems to me, that his algorithm is actually about the best you can do.
@kamilkarwacki9590
@kamilkarwacki9590 6 жыл бұрын
I dont agree, its fun writing my own algorithms
小路飞姐姐居然让路飞小路飞都消失了#海贼王  #路飞
00:47
路飞与唐舞桐
Рет қаралды 95 МЛН
WHY DOES SHE HAVE A REWARD? #youtubecreatorawards
00:41
Levsob
Рет қаралды 35 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 54 МЛН
КАК СПРЯТАТЬ КОНФЕТЫ
00:59
123 GO! Shorts Russian
Рет қаралды 2,9 МЛН
Delivering Safe C++ - Bjarne Stroustrup - CppCon 2023
1:29:16
CppCon 2017: Chandler Carruth “Going Nowhere Faster”
1:00:58
Why would a python programmer learn rust when there are no jobs in it
23:09
CppCon 2015: Andrei Alexandrescu “std::allocator...”
1:12:27
小路飞姐姐居然让路飞小路飞都消失了#海贼王  #路飞
00:47
路飞与唐舞桐
Рет қаралды 95 МЛН