GroveEngine/tests/benchmarks
StillHammer aefd7921b2 fix: Critical race conditions in ThreadedModuleSystem and logger
Fixed two critical race conditions that prevented multi-threaded module execution:

## Bug #1: ThreadedModuleSystem::registerModule() race condition

**Symptom:** Deadlock on first processModules() call
**Root Cause:** Worker thread started before being added to workers vector
**Fix:** Add worker to vector BEFORE spawning thread (src/ThreadedModuleSystem.cpp:102-108)

Before:
- Create worker → Start thread → Add to vector (RACE!)
- Thread accesses workers[index] before push_back completes

After:
- Create worker → Add to vector → Start thread (SAFE)
- Thread guaranteed to find worker in vector

## Bug #2: stillhammer::createLogger() race condition

**Symptom:** Deadlock when multiple threads create loggers simultaneously
**Root Cause:** Check-then-register pattern without mutex protection
**Fix:** Added static mutex around spdlog::get() + register_logger() (external/StillHammer/logger/src/Logger.cpp:94-96)

Before:
- Thread 1: check → create → register
- Thread 2: check → create → register (RACE on spdlog registry!)

After:
- Mutex protects entire check-then-register critical section

## Validation & Testing

Added comprehensive test suite:
- test_threaded_module_system.cpp (6 unit tests)
- test_threaded_stress.cpp (5 stress tests: 50 modules × 1000 frames)
- test_logger_threadsafe.cpp (concurrent logger creation)
- benchmark_threaded_vs_sequential.cpp (performance comparison)
- docs/THREADED_MODULE_SYSTEM_VALIDATION.md (full validation report)

All tests passing (100%):
- ThreadedModuleSystem:  0.15s
- ThreadedStress:  7.64s
- LoggerThreadSafe:  0.13s

## Impact

ThreadedModuleSystem now PRODUCTION READY:
- Thread-safe module registration
- Stable parallel execution (validated with 50,000+ operations)
- Hot-reload working (100 cycles tested)
- Logger thread-safe for concurrent module initialization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 07:37:31 +07:00
..
helpers feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
plans feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
benchmark_batching.cpp feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
benchmark_e2e.cpp feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
benchmark_helpers_demo.cpp feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
benchmark_readonly.cpp feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00
benchmark_threaded_vs_sequential.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
benchmark_topictree.cpp feat: Add comprehensive benchmark suite for GroveEngine performance validation 2025-11-20 16:08:10 +08:00