ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
Chaos Testing for Threads

Use chaos to validate stability under changing runtime conditions like CPU migrations and priority perturbations.

API

Header: include/threadschedule/chaos.hpp

using namespace threadschedule;
// Apply chaos to all threads with a specific component tag (uses global registry)
cfg.interval = std::chrono::milliseconds(200);
cfg.priority_jitter = 2; // +/-2 around baseline
cfg.shuffle_affinity = true; // periodically reshuffle to different NUMA CPUs
ChaosController controller(cfg, [](const RegisteredThreadInfo& e) {
return e.componentTag == "io";
});
// RAII: chaos runs until controller is destroyed
RAII controller that periodically perturbs scheduling attributes of registered threads for chaos/fuzz...
Definition chaos.hpp:86
Plain value type holding runtime chaos-testing parameters.
Definition chaos.hpp:34
int priority_jitter
+/- range applied around the current thread priority each interval.
Definition chaos.hpp:44
std::chrono::milliseconds interval
Definition chaos.hpp:36
Snapshot of metadata for a single registered thread.
Modern C++17/20/23/26 Thread Scheduling Library.

Tips

  • Limit chaos to a subset of threads via the predicate.
  • Keep intervals reasonable to avoid excessive thrashing.
  • Combine with logging/metrics to observe impact.