timeout: Fix performance regression using sigtimedwait
Resolves #9099
The timeout implementation was using a 100ms polling loop, causing
significant performance overhead (~100ms vs GNU's 1.1ms).
This commit replaces the polling approach with POSIX sigtimedwait(),
which suspends the process until SIGCHLD or timeout occurs, eliminating
the busy-wait overhead.
Key changes:
- Block SIGCHLD/SIGTERM before spawning child
- Use sigtimedwait() for efficient signal-based waiting
- Properly save and restore signal mask on all exit paths
- Handle EINTR correctly with timeout recalculation
Performance improvement:
- Before: 106.9ms ± 2.0ms
- After: 1.2ms ± 0.1ms
- GNU: 1.1ms ± 0.1ms
Tested with 100+ iterations, maintains 100% reliability.
68d69bd
2 days ago
by quantum-encoding
-0.01%
Fix signal mask inheritance preventing child processes from receiving SIGTERM (6 failing tests fixed)
19e65a8
2 days ago
by quantum-encoding
+0.02%
Fix formatting for CI
5e6ec5b
2 days ago
by quantum-encoding
-71.38%
Replace deprecated EventFlag with EvFlags
71a065c
6 hours ago
by quantum-encoding
+1.82%
Sort imports alphabetically
ec37bd0
6 hours ago
by quantum-encoding
+69.53%
Fix overflow with very large timeouts on macOS
2f191b5
5 hours ago
by quantum-encoding
+0.01%
Add FreeBSD kqueue support
2903644
5 hours ago
by quantum-encoding
-0.01%
Overflow fixes - Cap timespec conversions to prevent EINVAL with huge timeouts
e6d14b8
4 hours ago
by quantum-encoding
+0.03%
Use libc::time_t::MAX instead of i64::MAX
72d5443
3 hours ago
by quantum-encoding
0%
When parsing extremely large durations (like i64::MAX days), the conversion to seconds overflows. Instead of failing, cap the duration at time_t::MAX seconds, which is the maximum valid timeout value.
533a4e7
3 hours ago
by quantum-encoding
-0.01%
Cap duration at time_t::MAX seconds.
256817a
3 hours ago
by quantum-encoding
-0.01%
Check if numeric value is too large before calling parse_time to avoid overflow errors. If value exceeds safe limits, cap at time_t::MAX seconds instead of failing.