std::move doesn't move anything: A deep dive into Value Categories
https://0xghost.dev/blog/std-move-deep-dive/
https://redd.it/1pin1hj
@r_cpp
https://0xghost.dev/blog/std-move-deep-dive/
https://redd.it/1pin1hj
@r_cpp
0xghost.dev
std::move doesn't move anything: A deep dive into Value Categories
Why std::move is just a cast, how it kills RVO if used wrong, and the mechanics of ownership transfer.
Time in C++: std::chrono::high_resolution_clock — Myths and Realities
https://www.sandordargo.com/blog/2025/12/10/clocks-part-4-high_resolution_clock
https://redd.it/1piwky8
@r_cpp
https://www.sandordargo.com/blog/2025/12/10/clocks-part-4-high_resolution_clock
https://redd.it/1piwky8
@r_cpp
Sandor Dargo’s Blog
Time in C++: std::chrono::high_resolution_clock — Myths and Realities
If there’s one clock in <chrono> that causes the most confusion, it’s std::chrono::high_resolution_clock. The name sounds too tempting — who wouldn’t want “the highest resolution”? But like many things in C++, the details matter. In the earlier parts of this…
Ask Me Anything session with CLion team
Hi r/cpp,
The **CLion** team is excited to host an **AMA (Ask Me Anything)** session tomorrow **Thursday, December 11, 2025**.
Feel free to join us over at r/Jetbrains or drop your questions right here – we’ve got you covered!
[https://www.reddit.com/r/Jetbrains/comments/1pia836/ask\_me\_anything\_with\_clion\_team\_december\_11\_1\_pm/](https://www.reddit.com/r/Jetbrains/comments/1pia836/ask_me_anything_with_clion_team_december_11_1_pm/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)
[CLion](https://www.jetbrains.com/clion/) is a cross-platform IDE for C and C++ designed for smooth workflows and productive development. It is ready to use out of the box with all essential integrations in one place and supports major toolchains, popular build systems, unit testing frameworks, and advanced debugging, as well as embedded development.
This Q&A session will cover the latest updates and changes in CLion. Feel free to ask any questions about our latest 2025.3 release, CLion language engine updates and new language features, debugger enhancements, project models and build tools support, and anything else you're curious about!
**We’ll be answering your questions from 1–5 pm CET on December 11.**
**Your questions will be answered by:**
* Artemy Pestretsov (Head of the C/C++ Ecosystem) – u/artemypestretsov
* Andrey Gushchin (CLion Product Manager) – u/andrey-gushchin
* Evgenii Novozhilov (Engineering Lead) – u/ujohnny
* Aleksander Karaev (C/C++ Language Support Lead) – u/FortuneSpiritual6290
* Ilia Motornyi (CLion Developer, Embedded) – u/_elmot
There will be other members of the CLion team helping us behind the scenes.
We’re looking forward to seeing you!
Your CLion team,
JetBrains
https://redd.it/1piyfzp
@r_cpp
Hi r/cpp,
The **CLion** team is excited to host an **AMA (Ask Me Anything)** session tomorrow **Thursday, December 11, 2025**.
Feel free to join us over at r/Jetbrains or drop your questions right here – we’ve got you covered!
[https://www.reddit.com/r/Jetbrains/comments/1pia836/ask\_me\_anything\_with\_clion\_team\_december\_11\_1\_pm/](https://www.reddit.com/r/Jetbrains/comments/1pia836/ask_me_anything_with_clion_team_december_11_1_pm/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)
[CLion](https://www.jetbrains.com/clion/) is a cross-platform IDE for C and C++ designed for smooth workflows and productive development. It is ready to use out of the box with all essential integrations in one place and supports major toolchains, popular build systems, unit testing frameworks, and advanced debugging, as well as embedded development.
This Q&A session will cover the latest updates and changes in CLion. Feel free to ask any questions about our latest 2025.3 release, CLion language engine updates and new language features, debugger enhancements, project models and build tools support, and anything else you're curious about!
**We’ll be answering your questions from 1–5 pm CET on December 11.**
**Your questions will be answered by:**
* Artemy Pestretsov (Head of the C/C++ Ecosystem) – u/artemypestretsov
* Andrey Gushchin (CLion Product Manager) – u/andrey-gushchin
* Evgenii Novozhilov (Engineering Lead) – u/ujohnny
* Aleksander Karaev (C/C++ Language Support Lead) – u/FortuneSpiritual6290
* Ilia Motornyi (CLion Developer, Embedded) – u/_elmot
There will be other members of the CLion team helping us behind the scenes.
We’re looking forward to seeing you!
Your CLion team,
JetBrains
https://redd.it/1piyfzp
@r_cpp
Reddit
From the Jetbrains community on Reddit
Explore this post and more from the Jetbrains community
The Real Problem with C++: Mindset, Modern Practices and Safer Code – Interview with Klaus Iglberger
https://youtu.be/cjO76ygwGdA?si=5BVhhGMtDmLNB3gl
https://redd.it/1pizv9a
@r_cpp
https://youtu.be/cjO76ygwGdA?si=5BVhhGMtDmLNB3gl
https://redd.it/1pizv9a
@r_cpp
YouTube
The Real Problem with C++: Mindset, Modern Practices, & Safer Code – Interview with Klaus Iglberger
Is C++ really as unsafe as its reputation suggests, or is the real problem how we use it? In this episode of The Curious Developer, Jesper Pedersen (KDAB) sits down with Klaus Iglberger, author of "C++ Software Design Patterns," to discuss the challenges…
Visual Studio option /RTCc - what is its purpose?
Why does it exist?
Documentation says that it “Reports when a value is assigned to a smaller data type and results in a data loss.”
Except it is not what it actually does.
This runtime check reports a failure if discarded by a cast top bits are not the same (all 0 or all 1).
It is not a useful range check for either signed or unsigned types, almost as if someone did it to offend both equally...
I just can't understand why such an utterly useless option has been kept in a compiler for decades.
Am I missing something here?
https://redd.it/1pj0hyr
@r_cpp
Why does it exist?
Documentation says that it “Reports when a value is assigned to a smaller data type and results in a data loss.”
Except it is not what it actually does.
This runtime check reports a failure if discarded by a cast top bits are not the same (all 0 or all 1).
It is not a useful range check for either signed or unsigned types, almost as if someone did it to offend both equally...
I just can't understand why such an utterly useless option has been kept in a compiler for decades.
Am I missing something here?
https://redd.it/1pj0hyr
@r_cpp
Docs
/RTC (Run-time error checks)
The Microsoft C/C++ compiler /RTC options for run-time error checks.
What's better for robotics Cmake or Autotools ?
The noscript pretty much explains it. I recently watched CodingJesus video on the "C++ Wretch Build" (Like from Elden Ring) aka the build that will give you the least assitance to start out with but open up a lot of possibilities. I am very new to C++ and Robotics (just started with Arduino, Breadboard etc) In his video he detailed autotools was the best for getting "cracked" as a C++ developer. I want to be a robotics electrical engineer and I am aware that maybe some of his suggestions for this wretch build were maybe specific to developers.I asked chatgpt and google and the AI given answer was CMake was overwhelmingly better but I saw a lot of debate on reddit.
Context: This is his suggested "build"🌑
Wretch Starter Kit
Build System: Autotools
Debugger: GDB
IDE: Vim + tmux
Compiler: GCC
Linter: clang-tidy
Formatter: clang-format
Profiler: perf
git
https://redd.it/1pj4cy2
@r_cpp
The noscript pretty much explains it. I recently watched CodingJesus video on the "C++ Wretch Build" (Like from Elden Ring) aka the build that will give you the least assitance to start out with but open up a lot of possibilities. I am very new to C++ and Robotics (just started with Arduino, Breadboard etc) In his video he detailed autotools was the best for getting "cracked" as a C++ developer. I want to be a robotics electrical engineer and I am aware that maybe some of his suggestions for this wretch build were maybe specific to developers.I asked chatgpt and google and the AI given answer was CMake was overwhelmingly better but I saw a lot of debate on reddit.
Context: This is his suggested "build"🌑
Wretch Starter Kit
Build System: Autotools
Debugger: GDB
IDE: Vim + tmux
Compiler: GCC
Linter: clang-tidy
Formatter: clang-format
Profiler: perf
git
https://redd.it/1pj4cy2
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
How do compilers execute constexpr/consteval functions when you are cross-compiling?
I assume that you can not just compile and run for the host platform, since e.g.
Can the compiler just use the type sizes of the target platform, and then execute natively?
Can this problem be solved in different ways?
https://redd.it/1pj8qxk
@r_cpp
I assume that you can not just compile and run for the host platform, since e.g.
long can have a different size on the target platform.Can the compiler just use the type sizes of the target platform, and then execute natively?
Can this problem be solved in different ways?
https://redd.it/1pj8qxk
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Boost 1.90 – what to actually look at as a working C++ dev
https://www.boost.org/releases/1.90.0/
https://redd.it/1pjb8uc
@r_cpp
https://www.boost.org/releases/1.90.0/
https://redd.it/1pjb8uc
@r_cpp
www.boost.org
Boost 1.90.0
Discover what's new in Boost 1.90.0
A faster is-leap-year function for full-range signed 32-bit integers
https://www.benjoffe.com/fast-leap-year
https://redd.it/1pjenzm
@r_cpp
https://www.benjoffe.com/fast-leap-year
https://redd.it/1pjenzm
@r_cpp
Benjoffe
A New Faster Leap Year Function
A faster full-range 32-bit algorithm to convert determine whether a year is a leap year.
ACCU Overload Journal 190 - December 2025
https://accu.org/journals/overload/overload190
https://redd.it/1pjr9lr
@r_cpp
https://accu.org/journals/overload/overload190
https://redd.it/1pjr9lr
@r_cpp
accu.org
Overload Journal 190 - December 2025
ACCU - professionalism in programming
C++ Podcasts & Conference Talks (week 50, 2025)
Hi r/cpp! Welcome to another post in this series brought to you by Tech Talks Weekly. Below, you'll find all the C++ conference talks and podcasts published in the last 7 days:
# 📺 Conference talks
# CppCon 2025
1. **"Implementing Your Own C++ Atomics - Ben Saks - CppCon 2025"** ⸱ +4k views ⸱ 04 Dec 2025 ⸱ 01h 01m 38s
2. **"The Dangers of C++: How to Mitigate Them and Write Safe C++ - Assaf Tzur-El"** ⸱ +3k views ⸱ 03 Dec 2025 ⸱ 00h 50m 09s
3. **"Building Secure C++ Applications: A Practical End-to-End Approach - CppCon 2025"** ⸱ +2k views ⸱ 05 Dec 2025 ⸱ 01h 02m 01s
4. **"Back to Basics: How to Refactor C++ Code - Amir Kirsh"** ⸱ +2k views ⸱ 08 Dec 2025 ⸱ 01h 04m 13s
5. **"Is The Future of C++ Refactoring Declarative? - Andy Soffer - CppCon 2025"** ⸱ +1k views ⸱ 09 Dec 2025 ⸱ 01h 00m 49s
# ACCU York
1. **"Agentic Debugging Using Time Travel - Greg Law - ACCU York"** ⸱ +100 views ⸱ 09 Dec 2025 ⸱ 01h 06m 26s
# LMPL 2025
1. **"\[LMPL'25\ Challenges in C++ to Rust Translation with Large Language Models: A Preliminary(…)"](https://youtube.com/watch?v=HQDxhlxE1o&utmsource=techtalksweekly&utmmedium=email) ⸱ **<100 views** ⸱ 05 Dec 2025 ⸱ 00h 18m 10s
# OOPSLA 2025
1. [**"\[OOPSLA'25\] Fuzzing C++ Compilers via Type-Driven Mutation"**](https://youtube.com/watch?v=je8uYrTNfys&utmsource=techtalksweekly&utmmedium=email) ⸱ **<100 views** ⸱ 05 Dec 2025 ⸱ 00h 14m 13s
2. [**"\[OOPSLA'25\] Fast Constraint Synthesis for C++ Function Templates"**](https://youtube.com/watch?v=6pxVhEi-bc&utmsource=techtalksweekly&utmmedium=email) ⸱ <100 views ⸱ 05 Dec 2025 ⸱ 00h 13m 28s
# 🎧 Podcasts
1. **"C++ Memory Management • Patrice Roy & Kevin Carpenter"** ⸱ GOTO ⸱ 09 Dec 2025 ⸱ 00h 32m 20s
This post is an excerpt from the latest issue of ***Tech Talks Weekly*** which is a free weekly email with all the recently published Software Engineering podcasts and conference talks. Currently subscribed by +7,500 Software Engineers who stopped scrolling through messy YT subnoscriptions/RSS feeds and reduced FOMO. Consider subscribing if this sounds useful: *https://www.techtalksweekly.io/*
Let me know what you think. Thank you!
https://redd.it/1pjqqob
@r_cpp
Hi r/cpp! Welcome to another post in this series brought to you by Tech Talks Weekly. Below, you'll find all the C++ conference talks and podcasts published in the last 7 days:
# 📺 Conference talks
# CppCon 2025
1. **"Implementing Your Own C++ Atomics - Ben Saks - CppCon 2025"** ⸱ +4k views ⸱ 04 Dec 2025 ⸱ 01h 01m 38s
2. **"The Dangers of C++: How to Mitigate Them and Write Safe C++ - Assaf Tzur-El"** ⸱ +3k views ⸱ 03 Dec 2025 ⸱ 00h 50m 09s
3. **"Building Secure C++ Applications: A Practical End-to-End Approach - CppCon 2025"** ⸱ +2k views ⸱ 05 Dec 2025 ⸱ 01h 02m 01s
4. **"Back to Basics: How to Refactor C++ Code - Amir Kirsh"** ⸱ +2k views ⸱ 08 Dec 2025 ⸱ 01h 04m 13s
5. **"Is The Future of C++ Refactoring Declarative? - Andy Soffer - CppCon 2025"** ⸱ +1k views ⸱ 09 Dec 2025 ⸱ 01h 00m 49s
# ACCU York
1. **"Agentic Debugging Using Time Travel - Greg Law - ACCU York"** ⸱ +100 views ⸱ 09 Dec 2025 ⸱ 01h 06m 26s
# LMPL 2025
1. **"\[LMPL'25\ Challenges in C++ to Rust Translation with Large Language Models: A Preliminary(…)"](https://youtube.com/watch?v=HQDxhlxE1o&utmsource=techtalksweekly&utmmedium=email) ⸱ **<100 views** ⸱ 05 Dec 2025 ⸱ 00h 18m 10s
# OOPSLA 2025
1. [**"\[OOPSLA'25\] Fuzzing C++ Compilers via Type-Driven Mutation"**](https://youtube.com/watch?v=je8uYrTNfys&utmsource=techtalksweekly&utmmedium=email) ⸱ **<100 views** ⸱ 05 Dec 2025 ⸱ 00h 14m 13s
2. [**"\[OOPSLA'25\] Fast Constraint Synthesis for C++ Function Templates"**](https://youtube.com/watch?v=6pxVhEi-bc&utmsource=techtalksweekly&utmmedium=email) ⸱ <100 views ⸱ 05 Dec 2025 ⸱ 00h 13m 28s
# 🎧 Podcasts
1. **"C++ Memory Management • Patrice Roy & Kevin Carpenter"** ⸱ GOTO ⸱ 09 Dec 2025 ⸱ 00h 32m 20s
This post is an excerpt from the latest issue of ***Tech Talks Weekly*** which is a free weekly email with all the recently published Software Engineering podcasts and conference talks. Currently subscribed by +7,500 Software Engineers who stopped scrolling through messy YT subnoscriptions/RSS feeds and reduced FOMO. Consider subscribing if this sounds useful: *https://www.techtalksweekly.io/*
Let me know what you think. Thank you!
https://redd.it/1pjqqob
@r_cpp
www.techtalksweekly.io
Tech Talks Weekly | Substack
Join 7,200+ Software Engineers and Engineering Leaders who receive a free weekly email with all the recently published podcasts and conference talks. Stop scrolling through messy YT subnoscriptions. Stop FOMO. Easy to unsubscribe. No spam, ever. Click to read…
I optimized my Order Matching Engine by 560% (129k → 733k ops/sec) thanks to your feedback
Hey everyone,
A while back I shared my C++ Order Matching Engine here and got some "honest" feedback about my use of
I took that feedback to heart and spent the last week refactoring the core. Here are the results and the specific optimizations that worked:
The Results:
Baseline: \~129,000 orders/sec (MacBook Air)
Optimized: \~733,000 orders/sec
Speedup: 5.6x
The Optimizations:
1. Data Structure: `std::list` -> `std::deque` + Tombstones
Problem: My original implementation used
Fix: Switched to `std::deque`. It offers decent cache locality (chunked allocations) and pointer stability.
Trick: Instead of
2. Concurrency: Global Mutex -> Sharding
Problem: A single `std::mutex` protected the entire Exchange.
Fix: Implemented fine-grained locking. The Exchange now only holds a Shared (Read) lock to find the correct OrderBook. The OrderBook itself has a unique mutex. This allows massively parallel trading across different symbols.
3. The Hidden Bottleneck (Global Index)
I realized my cancelOrder(id) API required a global lookup map (`OrderId` \-> `Symbol`) to find which book an order belonged to. This map required a global lock, re-serializing my fancy sharded engine.
Fix: Changed API to cancelOrder(symbol, id). Removing that global index unlocked the final 40% performance boost.
The code is much cleaner now
I'd love to hear what you think of the new architecture. What would you optimize next? Custom Allocators? Lock-free ring buffers?
PS - I tried posting in the showcase section, but I got error "unable to create document" (maybe because I posted once recently, sorry a little new to reddit also)
Github Link - https://github.com/PIYUSH-KUMAR1809/order-matching-engine
https://redd.it/1pk5iv3
@r_cpp
Hey everyone,
A while back I shared my C++ Order Matching Engine here and got some "honest" feedback about my use of
std::list and global mutexes.I took that feedback to heart and spent the last week refactoring the core. Here are the results and the specific optimizations that worked:
The Results:
Baseline: \~129,000 orders/sec (MacBook Air)
Optimized: \~733,000 orders/sec
Speedup: 5.6x
The Optimizations:
1. Data Structure: `std::list` -> `std::deque` + Tombstones
Problem: My original implementation used
std::list to strictly preserve iterator validity. This killed cache locality.Fix: Switched to `std::deque`. It offers decent cache locality (chunked allocations) and pointer stability.
Trick: Instead of
erase() (which is O(N) for vector/deque), I implemented "Tombstone" deletion. Orders are marked active = false. The matching engine lazily cleans up dead orders from the front using pop_front() (O(1)).2. Concurrency: Global Mutex -> Sharding
Problem: A single `std::mutex` protected the entire Exchange.
Fix: Implemented fine-grained locking. The Exchange now only holds a Shared (Read) lock to find the correct OrderBook. The OrderBook itself has a unique mutex. This allows massively parallel trading across different symbols.
3. The Hidden Bottleneck (Global Index)
I realized my cancelOrder(id) API required a global lookup map (`OrderId` \-> `Symbol`) to find which book an order belonged to. This map required a global lock, re-serializing my fancy sharded engine.
Fix: Changed API to cancelOrder(symbol, id). Removing that global index unlocked the final 40% performance boost.
The code is much cleaner now
I'd love to hear what you think of the new architecture. What would you optimize next? Custom Allocators? Lock-free ring buffers?
PS - I tried posting in the showcase section, but I got error "unable to create document" (maybe because I posted once recently, sorry a little new to reddit also)
Github Link - https://github.com/PIYUSH-KUMAR1809/order-matching-engine
https://redd.it/1pk5iv3
@r_cpp
GitHub
GitHub - PIYUSH-KUMAR1809/order-matching-engine
Contribute to PIYUSH-KUMAR1809/order-matching-engine development by creating an account on GitHub.
Should I store a helper object as a class member or create it locally inside a method in C++?
I have a base
class Layer
{
public:
virtual ~Layer() {};
virtual void OnUpdate() {};
virtual void OnEvent() {};
virtual void OnRender() {};
Rescaler rescaler;
};
All other layer types in my application inherit from this class.
The
The user can set a custom window resolution for the application, and
This scaling is only needed during the
Given that:
1. the base
2. application-specific layers inherit from it,
3.
my question is:
Should
What is the recommended design in this scenario?
https://redd.it/1pk7x36
@r_cpp
I have a base
Layer class that I expose from a DLL. My application loads this DLL and then defines its own layer types that inherit from this base class. Here is the simplified definition:class Layer
{
public:
virtual ~Layer() {};
virtual void OnUpdate() {};
virtual void OnEvent() {};
virtual void OnRender() {};
Rescaler rescaler;
};
All other layer types in my application inherit from this class.
The
Rescaler object is responsible for scaling all drawing coordinates. The user can set a custom window resolution for the application, and
Rescaler converts the logical coordinates used by the layer into the final resolution used for rendering.This scaling is only needed during the
OnRender() step and it is not needed outside rendering.Given that:
1. the base
Layer class is part of a DLL,2. application-specific layers inherit from it,
3.
Rescaler is only used to scale rendering coordinates based on user-selected resolution,my question is:
Should
Rescaler remain a member of the base Layer class, be moved only into derived classes that actually need coordinate scaling, or simply be created locally inside OnRender()?What is the recommended design in this scenario?
https://redd.it/1pk7x36
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
I've built a text adventure game engine on top of the C++ Standard...
Why? I have no idea.
But it's a learning tool with quests and time travel and artifacts and NPC's and XP and ... well, you just have to check it out:
https://cppevo.dev/adventure
It's probably my favorite why to browse and search the standard now, but there's probably a few errors lurking in the conversion and maybe in the quests.
It's built on top of my C++ Standard -> markdown tool https://github.com/lefticus/cppstdmd and my C++ Evolution viewing tool https://cppevo.dev
Everything is cross linked where possible with other sites, and of course code samples NPCs give are linked back to Compiler Explorer.
https://redd.it/1pkasf6
@r_cpp
Why? I have no idea.
But it's a learning tool with quests and time travel and artifacts and NPC's and XP and ... well, you just have to check it out:
https://cppevo.dev/adventure
It's probably my favorite why to browse and search the standard now, but there's probably a few errors lurking in the conversion and maybe in the quests.
It's built on top of my C++ Standard -> markdown tool https://github.com/lefticus/cppstdmd and my C++ Evolution viewing tool https://cppevo.dev
Everything is cross linked where possible with other sites, and of course code samples NPCs give are linked back to Compiler Explorer.
https://redd.it/1pkasf6
@r_cpp
cppevo.dev
C++ Standard Adventure - cppevo
Explore the C++ standard as an interactive text adventure game. Navigate between C++ eras, collect knowledge, and learn the language.
How Modern C++ Parses a Word Document in a Clean Functional Pipeline
Working with old document formats often turns into archaeology — XML digging, platform-specific hacks, or very verbose parsing chains.
But modern C++20 allows a surprisingly clean, composable approach.
Here’s what a full MS Word (.doc or .docx) parsing pipeline looks like today using an operator-pipe style:
std::filesystem::path("data_processing_definition.doc")
| content_type::detector{}
| office_formats_parser{}
| PlainTextExporter()
| out_stream;
ensure(out_stream.str()) ==
"Data processing refers to the activities performed on raw data...";
No COM.
No platform-specific APIs.
No manual XML manipulation.
Just a functional, readable pipeline.
I'm honestly curious how other languages express a similar parsing chain.
If you work with Python, Rust, Go, Java, C#, or JS — how would you model this?
Would love to see your idiomatic equivalents.
https://redd.it/1pkekq6
@r_cpp
Working with old document formats often turns into archaeology — XML digging, platform-specific hacks, or very verbose parsing chains.
But modern C++20 allows a surprisingly clean, composable approach.
Here’s what a full MS Word (.doc or .docx) parsing pipeline looks like today using an operator-pipe style:
std::filesystem::path("data_processing_definition.doc")
| content_type::detector{}
| office_formats_parser{}
| PlainTextExporter()
| out_stream;
ensure(out_stream.str()) ==
"Data processing refers to the activities performed on raw data...";
No COM.
No platform-specific APIs.
No manual XML manipulation.
Just a functional, readable pipeline.
I'm honestly curious how other languages express a similar parsing chain.
If you work with Python, Rust, Go, Java, C#, or JS — how would you model this?
Would love to see your idiomatic equivalents.
https://redd.it/1pkekq6
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Show and Tell I optimized my Order Matching Engine by 560% (129k → 733k ops/sec) thanks to your feedback
Hey everyone,
A while back I shared my C++ Order Matching Engine here and got some "honest" feedback about my use of
I took that feedback to heart and spent the last week refactoring the core. Here are the results and the specific optimizations that worked:
The Results:
Baseline: \~129,000 orders/sec (MacBook Air)
Optimized: \~733,000 orders/sec
Speedup: 5.6x
The Optimizations:
1. Data Structure: `std::list` -> `std::deque` + Tombstones
Problem: My original implementation used
Fix: Switched to `std::deque`. It offers decent cache locality (chunked allocations) and pointer stability.
Trick: Instead of
2. Concurrency: Global Mutex -> Sharding
Problem: A single `std::mutex` protected the entire Exchange.
Fix: Implemented fine-grained locking. The Exchange now only holds a Shared (Read) lock to find the correct OrderBook. The OrderBook itself has a unique mutex. This allows massively parallel trading across different symbols.
3. The Hidden Bottleneck (Global Index)
I realized my cancelOrder(id) API required a global lookup map (`OrderId` \-> `Symbol`) to find which book an order belonged to. This map required a global lock, re-serializing my fancy sharded engine.
Fix: Changed API to cancelOrder(symbol, id). Removing that global index unlocked the final 40% performance boost.
The code is much cleaner now
I'd love to hear what you think of the new architecture. What would you optimize next? Custom Allocators? Lock-free ring buffers?
PS - I tried posting in the showcase section, but I got error "unable to create document" (maybe because I posted once recently, sorry a little new to reddit also). If anything is wrong with post, like wrong section etc. Please let me know how to fix it.
Github Link - https://github.com/PIYUSH-KUMAR1809/order-matching-engine
https://redd.it/1pkjpjw
@r_cpp
Hey everyone,
A while back I shared my C++ Order Matching Engine here and got some "honest" feedback about my use of
std::list and global mutexes.I took that feedback to heart and spent the last week refactoring the core. Here are the results and the specific optimizations that worked:
The Results:
Baseline: \~129,000 orders/sec (MacBook Air)
Optimized: \~733,000 orders/sec
Speedup: 5.6x
The Optimizations:
1. Data Structure: `std::list` -> `std::deque` + Tombstones
Problem: My original implementation used
std::list to strictly preserve iterator validity. This killed cache locality.Fix: Switched to `std::deque`. It offers decent cache locality (chunked allocations) and pointer stability.
Trick: Instead of
erase() (which is O(N) for vector/deque), I implemented "Tombstone" deletion. Orders are marked active = false. The matching engine lazily cleans up dead orders from the front using pop_front() (O(1)).2. Concurrency: Global Mutex -> Sharding
Problem: A single `std::mutex` protected the entire Exchange.
Fix: Implemented fine-grained locking. The Exchange now only holds a Shared (Read) lock to find the correct OrderBook. The OrderBook itself has a unique mutex. This allows massively parallel trading across different symbols.
3. The Hidden Bottleneck (Global Index)
I realized my cancelOrder(id) API required a global lookup map (`OrderId` \-> `Symbol`) to find which book an order belonged to. This map required a global lock, re-serializing my fancy sharded engine.
Fix: Changed API to cancelOrder(symbol, id). Removing that global index unlocked the final 40% performance boost.
The code is much cleaner now
I'd love to hear what you think of the new architecture. What would you optimize next? Custom Allocators? Lock-free ring buffers?
PS - I tried posting in the showcase section, but I got error "unable to create document" (maybe because I posted once recently, sorry a little new to reddit also). If anything is wrong with post, like wrong section etc. Please let me know how to fix it.
Github Link - https://github.com/PIYUSH-KUMAR1809/order-matching-engine
https://redd.it/1pkjpjw
@r_cpp
GitHub
GitHub - PIYUSH-KUMAR1809/order-matching-engine
Contribute to PIYUSH-KUMAR1809/order-matching-engine development by creating an account on GitHub.
The State of C++ 2025 (JetBrains survey)
https://lp.jetbrains.com/the-state-of-cpp-2025/
https://redd.it/1pkozlz
@r_cpp
https://lp.jetbrains.com/the-state-of-cpp-2025/
https://redd.it/1pkozlz
@r_cpp
JetBrains: Developer Tools for Professionals and Teams
The State of C++ 2025
Based on responses from 1,800 C++ developers from 22 countries, The State of C++ 2025 shows how C++ is adapting to modern development trends while staying true to its performance-oriented roots.
What makes a game tick? Part 8 - Data Driven Multi-Threading Implementation · Mathieu Ropert
https://mropert.github.io/2025/12/11/making_games_tick_part8/
https://redd.it/1pktgc3
@r_cpp
https://mropert.github.io/2025/12/11/making_games_tick_part8/
https://redd.it/1pktgc3
@r_cpp
mropert.github.io
What makes a game tick? Part 8 - Data Driven Multi-Threading Implementation · Mathieu Ropert
Let’s talk about game simulations. Today we dive into the nitty-gritty bits of implementing data driven multi-threading.
Parallel C++ for Scientific Applications: Introduction to Parallelism
https://www.youtube.com/watch?v=kA7A5sWFstw
https://redd.it/1pkueou
@r_cpp
https://www.youtube.com/watch?v=kA7A5sWFstw
https://redd.it/1pkueou
@r_cpp
YouTube
CSC4700-Introduction to Parallelism
This lecture provides an introduction to parallelism in computing, focusing on the challenges and considerations involved in writing parallel programs. The lecture covers different types of parallel computing architectures (shared memory, distributed memory…
C++26 Reflection appreciation post
I have been tinkering with reflection on some concrete side project for some times, (using the Clang experimental implementation : https://github.com/bloomberg/clang-p2996 ) and I am quite stunned by how well everything clicks together.
The whole this is a bliss to work with. It feels like every corner case has been accounted for. Every hurdle I come across, I take a look at one of the paper and find out a solution already exists.
It takes a bit of getting used to this new way of mixing constant and runtime context, but even outside of papers strictly about reflection, new papers have been integrated to smooth things a lot !
I want to give my sincere thanks and congratulations to everyone involved with each and every paper related to reflection, directly or indirectly.
I am really stunned and hyped by the work done.
https://redd.it/1pl7t3p
@r_cpp
I have been tinkering with reflection on some concrete side project for some times, (using the Clang experimental implementation : https://github.com/bloomberg/clang-p2996 ) and I am quite stunned by how well everything clicks together.
The whole this is a bliss to work with. It feels like every corner case has been accounted for. Every hurdle I come across, I take a look at one of the paper and find out a solution already exists.
It takes a bit of getting used to this new way of mixing constant and runtime context, but even outside of papers strictly about reflection, new papers have been integrated to smooth things a lot !
I want to give my sincere thanks and congratulations to everyone involved with each and every paper related to reflection, directly or indirectly.
I am really stunned and hyped by the work done.
https://redd.it/1pl7t3p
@r_cpp
GitHub
GitHub - bloomberg/clang-p2996: Experimental clang support for WG21 P2996 (Reflection).
Experimental clang support for WG21 P2996 (Reflection). - bloomberg/clang-p2996
How to make my C++ project portable.
So about 15 years ago when I was at ITT Tech, I made a simple project. Basically a Mega Man 2 BGM selection menu. I ran into 2 issues when I actually presented my project.
\#1 I tried to be clever and assign the file directory to my thumb drive. At the time it was my D: drive. When I went to present the project, the computer reassigned my thumb drive's letter because the presenting computer (unbeknownst to me) already had a D: drive. So the program broke because it couldn't reference the locations of the music files it was playing. Ok no problem. I grab my own laptop and continue on.
\#2 A few weeks ago, I go back and take a look at the program. My son is taking a computer science class in high school, and I want to show him what I was doing when I started getting into programming. Kinda an inspiration, idea jogging type of thing. So I go to load the program. I start researching how to fix the reference issue. Ok I got that. Cool so I can now send my program to him, and my own high school buddy who is getting into programming himself a little bit.
They get the file and try to run the exe. They get 4 errors:
\-"The code execution cannot proceed because MSVCP140D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because VCRUNTIME140D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because VCRUNTIME140_1D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because ucertbased.dll was not found. Reinstalling the program may fix this problem."
There's nothing to install. It's just an executable compiled by Visual Basic compiler. Maybe that's the problem. How do I get these 4 files, and how can I send them in such a way that my program can be run (or installed to run) on another computer. I'm guessing I have the files on my laptop because they came with Visual Basic? I'm not sure, but it seems like a big ask to have end users download Visual Basic just to run an exe.
https://redd.it/1plcbb1
@r_cpp
So about 15 years ago when I was at ITT Tech, I made a simple project. Basically a Mega Man 2 BGM selection menu. I ran into 2 issues when I actually presented my project.
\#1 I tried to be clever and assign the file directory to my thumb drive. At the time it was my D: drive. When I went to present the project, the computer reassigned my thumb drive's letter because the presenting computer (unbeknownst to me) already had a D: drive. So the program broke because it couldn't reference the locations of the music files it was playing. Ok no problem. I grab my own laptop and continue on.
\#2 A few weeks ago, I go back and take a look at the program. My son is taking a computer science class in high school, and I want to show him what I was doing when I started getting into programming. Kinda an inspiration, idea jogging type of thing. So I go to load the program. I start researching how to fix the reference issue. Ok I got that. Cool so I can now send my program to him, and my own high school buddy who is getting into programming himself a little bit.
They get the file and try to run the exe. They get 4 errors:
\-"The code execution cannot proceed because MSVCP140D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because VCRUNTIME140D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because VCRUNTIME140_1D.dll was not found. Reinstalling the program may fix this problem."
\-"The code execution cannot proceed because ucertbased.dll was not found. Reinstalling the program may fix this problem."
There's nothing to install. It's just an executable compiled by Visual Basic compiler. Maybe that's the problem. How do I get these 4 files, and how can I send them in such a way that my program can be run (or installed to run) on another computer. I'm guessing I have the files on my laptop because they came with Visual Basic? I'm not sure, but it seems like a big ask to have end users download Visual Basic just to run an exe.
https://redd.it/1plcbb1
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community