feat(presentation): raise frame-scheduler thread priority - #37
Merged
Conversation
Elevate the laser-frame-scheduler thread to ThreadPriority::Max so its pacing sleeps are less likely to be preempted under system load, reducing output timing jitter. Best-effort: on systems that disallow raising priority without privileges (e.g. Linux without CAP_SYS_NICE) it logs a warning and continues at default priority rather than failing the session. Uses the cross-platform thread-priority crate (deferred from #26). Max maps into the current scheduling policy's range, so it needs no elevated privileges on macOS/Windows and falls back to niceness on Linux. Closes #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Elevates the
laser-frame-schedulerthread toThreadPriority::Maxso its pacing sleeps are less likely to be preempted under system load, reducing output timing jitter. Resolves the follow-up deferred from #26.The call is best-effort: on systems that disallow raising priority without privileges (e.g. Linux without
CAP_SYS_NICE) it logs a warning and continues at default priority rather than failing the session.Why
Maxand not true realtimethread-priority'sset_current_thread_prioritymaps the requested priority into the current scheduling policy's allowed range rather than forcing a realtime policy. SoMax:SCHED_OTHERon Linux,avoiding the system-starvation and privilege pitfalls of
SCHED_FIFOwhile still nudging the scheduler in our favor.Changes
Cargo.toml/Cargo.lock: add cross-platformthread-priority = "3"(always-on).src/presentation/session.rs: raise priority as the scheduler thread's first action (inside the closure, so it targets the correct OS thread); warn-and-continue on failure.Testing
cargo buildclean,cargo clippyclean.Okon macOS without special privileges.Closes #35