Rico's Nerd Cluster

「离开世界之前 一切都是过程」

C++ - [Concurrency 10] Mutable Variables

Mutable Variable In this example, we are able to change a mutable variable in a const function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include <iostream> #include...

C++ - [Concurrency 9] Scoped Lock and `adopt_lock`

adopt_lock In a bank transfer system, if we transfer A->B and B->A concurrently. std::lock() locks two locks in a dead-lock free way, but does not unlock automatically, so we need to unlock ...

C++ - [Concurrency 8] `std::this_thread::yield()`

Introduction std::this_thread::yield() is used in a case where you are busy waiting and fighting for CPU time slices. It will give the scheduler a hint that other threads could come in and finsih ...

C++ - [Concurrency 1] Multithreaded Programming

`std::thread`, mutex, atomic_variables, Threading-Monitoring

Threading Motivation: Why C++ Concurrency Matters Standardized concurrency arrived with C++11, replacing the ad-hoc C / compiler-specific APIs used before C++98 with a formal memory model. Key l...

C++ - [Memory Access - 1] Layout

Cache

Memory Access: The Hidden Bottleneck Reference Why Memory Access Matters Even as CPU speeds continue to improve, the cost of fetching data from memory has become a limiting factor. Operating sys...

C++ Tool Websites

CppInsights, Compiler Explorer, Conan

CppInsights CppInsights does these things: how the standard library objects (like stringstream, vector, etc.) get instantiated how overloaded operators are actually resolved. 1 2 3 4 5 6 7...

Perf

Perf

perf Reference: cnblogs post Prerequisites: Permissions By default, many distros set perf_event_paranoid=4, which blocks hardware counter access for unprivileged users. Check and fix: 1 2 3...

C++ Profiling and Speed Ups

gprof, CMake Release and Debug BoilerPlate, CMake Settings

Gprof GNU gprof provides CPU execution times (not wall time, so sleep is not accounted for) of functions and their subfunctions in percentage. Gprof outputs data in a text-based format, which can ...

C++ - GTest

GTest For ROS

Concepts Google Test (a.k.a GTest) is an open source unit testing structure. From the official website Test Suite vs Test Case: A test suite contains one or many tests. You should group your t...

GDB, DDD (Data Display Debugger)

GDB for ROS, Core Dump

Introduction GDB is EXTREMELY handy. I used to doing a lot of print statements, but now I use GDB a lot. The reason is simple: I can check multiple things at once without recompiling everytime, es...