FreeBSD: use eventfd and timerfd for CFRunloop #5539
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 222 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.323
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5539"
general
weight: 0.35
michael-yuji
FreeBSD currently use the generic kqueue / pipe2 mechanism from to crash if more more MAX_TIMERS are created (hardcoded to 16)
Since both eventfd and timerfd are available on FreeBSD, use that instead of pipe2 and EVFILT_TIMER
This is an ABI change on FreeBSD and also requires a libdispatch change: https://github.com/swiftlang/swift-corelibs-libdispatch/pull/957
Motivation:
FreeBSD currently use the
EVFILT_TIMERmechanism for timer, andpipe2as trigger from #3004. There are fewissues with this
MAX_TIMERS(currently 16+1) timers, and led to crashes if extra timer are created. https://github.com/swiftlang/swift-corelibs-foundation/blob/761b621da93a856a48995efc29ed11028c283306/Sources/CoreFoundation/CFRunLoop.c#L522https://github.com/swiftlang/swift-corelibs-foundation/blob/761b621da93a856a48995efc29ed11028c283306/Sources/CoreFoundation/CFRunLoop.c#L1146
MAX_TIMERS, there's a system-wise limit (kern.kq_calloutmax) on how many timers allowed in kqueue (default is 4096 timers across the entire system).timerfddoes not have such limitationpipe2mechanism,__CFPortis encoded in a specific way to be able to both encode 2 file descriptors and aEVFILT_TIMER. since we're moving totimerfd, we can just that theeventfdbranch instead. This also resolve a potential issue where in theory the runloop wakeup can stall if we write to a pipe with full buffer.Modifications:
Align FreeBSD runloop timer and awaking mechanism with Linux, using
timerfdandeventfdinstead ofEVFILT_TIMERandpipe2CFPortSet is still a kqueue
Result:
Running on FreeBSD not longer bounded by the
MAX_TIMERSlimit and system-wisekern.kq_calloutmaxlimit