Expand description
Watchdog timer for detecting stuck strands
Monitors strand execution time and triggers alerts when strands run too long without yielding. This helps detect infinite loops and runaway computation.
§Configuration (Environment Variables)
| Variable | Default | Description |
|---|---|---|
SEQ_WATCHDOG_SECS | 0 (disabled) | Threshold in seconds for “stuck” strand |
SEQ_WATCHDOG_INTERVAL | 5 | Check frequency in seconds |
SEQ_WATCHDOG_ACTION | warn | Action: warn (dump diagnostics) or exit (terminate) |
§Example
# Enable watchdog with 30 second threshold, check every 10 seconds
SEQ_WATCHDOG_SECS=30 SEQ_WATCHDOG_INTERVAL=10 ./my-program
# Enable watchdog that exits on stuck strand
SEQ_WATCHDOG_SECS=60 SEQ_WATCHDOG_ACTION=exit ./my-program§Design
The watchdog runs on a dedicated thread and periodically scans the strand registry. It compares each strand’s spawn time against the current time to detect strands that have been running longer than the threshold.
This piggybacks on the existing strand registry infrastructure, requiring no additional tracking overhead on the hot path.
§Feature Flag
This module requires the diagnostics feature (enabled by default).
When disabled, the watchdog is not compiled.
Structs§
- Watchdog
Config - Watchdog configuration
Enums§
- Watchdog
Action - Action to take when watchdog detects a stuck strand
Functions§
- install_
watchdog - Install the watchdog timer