stonetor - goto conference...•aeron and c++? • what constitutes modern c++?• how aeron adopts...
TRANSCRIPT
![Page 1: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/1.jpg)
Using Modern C++ In Anger
Todd L. Montgomery @toddlmontgomery
StoneTor
![Page 2: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/2.jpg)
•Aeron and C++?
• What constitutes Modern C++? • How Aeron Adopts Modern C++?
• What Lessons were learned?
• What’s Next?
![Page 3: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/3.jpg)
Aeron and C++?
![Page 4: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/4.jpg)
Truly modern messaging transport
![Page 5: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/5.jpg)
Feature Bloat & Complexity
![Page 6: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/6.jpg)
Not Fast Enough
![Page 7: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/7.jpg)
Low & Predictable Latency is key
![Page 8: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/8.jpg)
We are in a new world
Multi-core, Multi-socket, Cloud...
![Page 9: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/9.jpg)
We are in a new world
UDP, IPC, InfiniBand,RDMA, PCI-e
Multi-core, Multi-socket, Cloud...
![Page 10: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/10.jpg)
Aeron is trying a new approach
![Page 11: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/11.jpg)
The Team
Todd Montgomery Richard Warburton
Martin Thompson
![Page 12: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/12.jpg)
Publishers SubscribersChannel
Stream
Messaging
Channel
![Page 13: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/13.jpg)
A library, not a framework, on which other abstractions and
applications can be built
![Page 14: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/14.jpg)
Composable Design
![Page 15: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/15.jpg)
OSI layer 4 Transport for message oriented streams
![Page 16: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/16.jpg)
OSI Layer 4 (Transport) Services
1. Connection Oriented Communication
2. Reliability 3. Flow Control
4. Congestion Avoidance/Control
5. Multiplexing
![Page 17: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/17.jpg)
Multi-Everything World!
![Page 18: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/18.jpg)
Publishers Subscribers
Channel
Stream
Multi-Everything World
![Page 19: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/19.jpg)
Design Principles
1. Garbage free in steady state running 2. Smart Batching in the message path
3. Wait-free algos in the message path
4. Non-blocking IO in the message path
5. No exceptional cases in message path
6. Apply the Single Writer Principle
7. Prefer unshared state
8. Avoid unnecessary data copies
![Page 20: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/20.jpg)
Publisher
Subscriber
Subscriber
Publisher
Architecture
IPC Log Buffer
![Page 21: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/21.jpg)
Sender
Receiver
Receiver
Sender
Publisher
Subscriber
Subscriber
Publisher
Architecture
Media
IPC Log BufferMedia (UDP, InfiniBand, PCI-e 3.0)
![Page 22: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/22.jpg)
Conductor
Sender
Receiver
Conductor
Receiver
Sender
Publisher
Subscriber
Subscriber
Publisher
Admin
Events
Architecture
Admin
EventsMedia
IPC Log BufferMedia (UDP, InfiniBand, PCI-e 3.0)Function/Method CallVolatile Fields & Queues
![Page 23: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/23.jpg)
ClientMedia DriverMedia Driver
Conductor
Sender
Receiver
Conductor
Receiver
Sender
Client
Publisher
Conductor Conductor
Subscriber
Subscriber
Publisher
Admin
Events
Architecture
Admin
EventsMedia
IPC Log Buffer
IPC Ring/Broadcast Buffer
Media (UDP, InfiniBand, PCI-e 3.0)Function/Method CallVolatile Fields & Queues
![Page 24: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/24.jpg)
C++?
![Page 25: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/25.jpg)
ClientMedia DriverMedia Driver
Conductor
Sender
Receiver
Conductor
Receiver
Sender
Client
Publisher
Conductor Conductor
Subscriber
Subscriber
Publisher
Admin
Events
Architecture
Admin
EventsMedia
IPC Log Buffer
IPC Ring/Broadcast Buffer
Media (UDP, InfiniBand, PCI-e 3.0)Function/Method CallVolatile Fields & Queues
![Page 26: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/26.jpg)
ClientMedia DriverMedia Driver
Conductor
Sender
Receiver
Conductor
Receiver
Sender
Client
Publisher
Conductor Conductor
Subscriber
Subscriber
Publisher
Admin
Events
Architecture
Admin
EventsMedia
IPC Log Buffer
IPC Ring/Broadcast Buffer
Media (UDP, InfiniBand, PCI-e 3.0)Function/Method CallVolatile Fields & Queues
Client • Application API • Java, C, C++, C#, etc.
![Page 27: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/27.jpg)
The Media Driver is (currently) Java…
![Page 28: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/28.jpg)
![Page 29: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/29.jpg)
What constitutes Modern C++?
![Page 30: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/30.jpg)
![Page 31: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/31.jpg)
![Page 32: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/32.jpg)
Modern C++
![Page 33: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/33.jpg)
Resource Ownership & Lifetime
![Page 34: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/34.jpg)
Modern C++
• Idioms (RAII, etc.)
![Page 35: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/35.jpg)
std::lock_guard std::unique_ptr
Resource Acquisition is Initialization (RAII)
http://en.cppreference.com/w/cpp/language/raii
![Page 36: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/36.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
![Page 37: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/37.jpg)
std::shared_ptr std::unique_ptr std::weak_ptr
Smart Pointers
http://en.cppreference.com/w/cpp/memory
![Page 38: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/38.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
• Lambda's & Function Objects
![Page 39: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/39.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic)
![Page 40: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/40.jpg)
std::atomic<bool> std::atomic_flag
Atomic Operations
http://en.cppreference.com/w/cpp/atomic
![Page 41: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/41.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic)
• Thread Support
![Page 42: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/42.jpg)
std::thread std::mutex std::promise std::future
Thread Support
http://en.cppreference.com/w/cpp/thread
![Page 43: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/43.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic)
• Thread Support • Move Construction/Assignment
![Page 44: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/44.jpg)
Modern C++
• Idioms (RAII, etc.) • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic)
• Thread Support • Move Construction/Assignment • Toolchain (Build/Test)
![Page 45: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/45.jpg)
CMake Google Test
Google Mock etc.
Modern Toolchain
https://cmake.org/https://github.com/google/googletest
![Page 46: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/46.jpg)
How Aeron Adopts Modern C++?
![Page 47: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/47.jpg)
Smart Pointers
![Page 48: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/48.jpg)
Lambda’s & Function Objects
![Page 49: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/49.jpg)
Thread Support
![Page 50: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/50.jpg)
What Lessons were learned?
![Page 51: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/51.jpg)
Lessons - What do you think?
• Idioms (RAII, etc.) • Stack Allocation • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic) • Thread Support • Move Construction/Assignment • Toolchain (Build/Test)
![Page 52: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/52.jpg)
Lessons
• Idioms (RAII, etc.) • Stack Allocation • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic) • Thread Support • Move Construction/Assignment • Toolchain (Build/Test)
![Page 53: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/53.jpg)
![Page 54: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/54.jpg)
RAII & Smart Pointers
• Give in to Smart Pointers
![Page 55: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/55.jpg)
RAII & Smart Pointers
• Give in to Smart Pointers • Explicit Coupling
![Page 56: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/56.jpg)
RAII & Smart Pointers
• Give in to Smart Pointers • Explicit Coupling • Explicit Scoping
![Page 57: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/57.jpg)
[insert excuse Y] …
Escape Analysis Value Types
…
Stack Allocation (Lack of)
![Page 58: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/58.jpg)
![Page 59: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/59.jpg)
![Page 60: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/60.jpg)
Lessons
• Idioms (RAII, etc.) • Stack Allocation • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic) • Thread Support • Move Construction/Assignment • Toolchain (Build/Test)
![Page 61: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/61.jpg)
![Page 62: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/62.jpg)
Move Construction/Assignment
• Much more than you think
![Page 63: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/63.jpg)
Move Construction/Assignment
• Much more than you think • Sometimes/Often better to copy
![Page 64: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/64.jpg)
Move Construction/Assignment
• Much more than you think • Sometimes/Often better to copy • Optimization Interactions
![Page 65: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/65.jpg)
Move Construction/Assignment
• Much more than you think • Sometimes/Often better to copy • Optimization Interactions • When you have to do it… why?!?
![Page 66: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/66.jpg)
Lessons
• Idioms (RAII, etc.) • Stack Allocation • Smart Pointers
• Lambda's & Function Objects
• Atomics (std::atomic) • Thread Support • Move Construction/Assignment • Toolchain (Build/Test)
![Page 67: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/67.jpg)
![Page 68: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/68.jpg)
ClientMedia DriverMedia Driver
Conductor
Sender
Receiver
Conductor
Receiver
Sender
Client
Publisher
Conductor Conductor
Subscriber
Subscriber
Publisher
Admin
Events
Architecture
Admin
EventsMedia
IPC Log Buffer
IPC Ring/Broadcast Buffer
Media (UDP, InfiniBand, PCI-e 3.0)Function/Method CallVolatile Fields & Queues
![Page 69: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/69.jpg)
Data Structures (Shared Memory)
• IPC Ring Buffers
• IPC Broadcast Buffers
• IPC Log Buffers
![Page 70: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/70.jpg)
Creates a replicated persistent log
of messages
What Aeron does
![Page 71: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/71.jpg)
TailFile
![Page 72: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/72.jpg)
Tail
File
Message 1Header
![Page 73: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/73.jpg)
Tail
File
Message 1Header
Message 2
Header
![Page 74: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/74.jpg)
Tail
File
Message 1Header
Message 2
Header
![Page 75: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/75.jpg)
Tail
File
Message 1Header
Message 2
Header
Message 3
![Page 76: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/76.jpg)
Tail
File
Message 1Header
Message 2
Header
Message 3
Header
![Page 77: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/77.jpg)
Log Buffer File
Term 0
Term 1
Term 2
Term Meta Data 0
Term Meta Data 2
Term Meta Data 1
Log Meta Data
![Page 78: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/78.jpg)
Log Buffer File
Term 0
Term 1
Term 2
Term Meta Data 0
Term Meta Data 2
Term Meta Data 1
Log Meta DataA
tom
ic &
Ord
ere
d O
pe
ratio
ns
![Page 79: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/79.jpg)
Position
![Page 80: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/80.jpg)
Unique identification of a byte within each stream
![Page 81: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/81.jpg)
Publishers, Senders, Receivers, and Subscribers all keep position counters
![Page 82: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/82.jpg)
Position counters are the key toflow control and monitoring
![Page 83: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/83.jpg)
Statistics & Position Counters are accessible in shared memory
Atomic & Ordered Operations
![Page 84: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/84.jpg)
Multiple Challenges
• Size (and Layout) • Memory Models (C++11 to Java)
![Page 85: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/85.jpg)
Size Matters
![Page 86: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/86.jpg)
![Page 87: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/87.jpg)
Size Matters (Atomics)
• Not designed for arbitrary memory • Size not the same as the types • Concerned only with operations
![Page 88: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/88.jpg)
Memory Models
• Interoperability with JMM • std::memory_order fit for purpose
![Page 89: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/89.jpg)
So…
Aeron uses its own atomic operations C/C++ functions
(JMM compatible)
*gccx86_64initiallycontributedbyphaynes([email protected])
![Page 90: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/90.jpg)
What’s Next?
![Page 91: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/91.jpg)
Finished a few passes ofProfiling and Tuning
![Page 92: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/92.jpg)
C++ to C++ 32+ Million messages per
second
IPC, 32-byte Messages
![Page 93: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/93.jpg)
C++: 32M msg/sec Java: 30M msg/sec .NET: 15M msg/sec
IPC, 32-byte Messages
![Page 94: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/94.jpg)
Replication
Services
Aeron Core
Persistence
PerformanceC/C++ Driver
Multi Unicast Send
Efficient FEC
Encryption/Security
1.0!!
![Page 95: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/95.jpg)
In closing…
![Page 96: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/96.jpg)
![Page 97: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/97.jpg)
https://github.com/real-logic/Aeron
Where can I find it?
![Page 98: StoneTor - GOTO Conference...•Aeron and C++? • What constitutes Modern C++?• How Aeron Adopts Modern C++?• What Lessons were learned?• What’s Next?Design Principles 1](https://reader030.vdocuments.mx/reader030/viewer/2022040215/5ed61881bcb22c51e2620e14/html5/thumbnails/98.jpg)
Aeron: https://github.com/real-logic/Aeron Twitter: @toddlmontgomery
Thank You!
Questions?