HackerTube

CppCon 2015: Andrei Alexandrescu “std::allocator...”

CppCon7 HN recommenders · recommended in 11 months, 2017–2025
YouTube
talk · advanced · evergreen · 2017–2025 on HN

Andrei Alexandrescu's CppCon 2015 talk argues that std::allocator is badly designed. He proposes building high-performance allocators from small composable, templated pieces.

HN repeatedly recommends it as an entertaining, mind-opening talk on allocator design and composable generic programming.

12 comments from Hacker News

@jiggawatts2025-01 · in “Comptime as Configuration”

> The issue with this approach is that the more you can control, the less the compiler can assume. That's absolutely true, but there's a workaround, albeit a complicated one. The compiler internals need the same kind of constraints or traits that abstract code such as language interfaces or template parameters can have. These can then be used to constrain the internals in a way that then would allow assumptions to be safely "plumbed through" the various layers. The (big!) challenge here is that these abstractions haven't been well-developed in the industry. Certainly nowhere near as well as the typical runtime "type theory" as seen in modern languages. > some very basic ones like allocating heap memory. Well... this is sort-of my point! For example, what's the fundamental difference between allocating memory in some heap[1] structure at runtime and a compiler allocating members in a struct/record/class for optimal packing? IMHO, not much. E.g.: Watch this talk by Andrei Alexandrescu titled "std::allocator Is to Allocation what std::vector Is to Vexation": ▶ this video It really opened my eyes to how one could very elegantly make a very complex and high-performance heap allocator from trivial parts composed at compile-time. There's no reason that a nearly identical abstraction couldn't also be used to efficiently "bin pack" variables into a struct. E.g.: accounting for alignment, collecting like-sized items into contiguous sections, extra padding for "lock" objects to prevent cache

Strongly recommends View on HN
@jiggawatts2023-01 · in “Ask HN: What's the best lecture series you've ever seen?”

Not exactly a lecture series, but Andrei Alexandrescu has had some fantastic keynote presentations at CppCon. I don't even program in C++ any more, but I've watched these more than once, they're entertaining, approachable, and inspiring: Speed Is Found In The Minds of People link std::allocator Is to Allocation what std::vector Is to Vexation ▶ this video An actual lecture series I've enjoyed watching is "The WE-Heraeus International Winter School on Gravity and Light", which covers General Relativity using modern mathematical approaches: link Again, I haven't done physics in 20 years, but I've found it surprisingly easy to follow because it is so clearly presented.

Strongly recommends View on HN
@jiggawatts2020-12 · in “Writing a Memory Allocator (2019)”

Every time I hear someone talking about writing a memory allocator, it always reminds me of the brilliant CppCon 2015 talk by Andrei Alexandrescu about how he wrote an modular allocator library that can be built up in pieces to make whatever you like. ▶ this video

Strongly recommends View on HN
@favorited2020-10 · in “Custom Allocators Demystified”

Andrei Alexandrescu's 2015 talk about C++'s allocators is great. He's a very entertaining presenter, and he makes case for extremely composable templated allocators (and why std::allocator isn't that). ▶ this video

Strongly recommends View on HN
@favorited2020-04 · in “Benchmarking C++ Allocators”

A bit unrelated, but if anyone is interested, I recently watched Andrei Alexandrescu's 2015 talk about a composable allocator design in C++ and it was really interesting. And Andrei's presentation style was fantastic, per usual. Note that this talk is about a std::allocator-like type, potentially on top of one of malloc/jemalloc/etc. ▶ this video

Strongly recommends View on HN