Skip to content

feat(utils): scoped frame-pacing helper for trial loops#326

Open
pellet wants to merge 2 commits into
NeuroTechX:masterfrom
pellet:feat/realtime-frame-pacing
Open

feat(utils): scoped frame-pacing helper for trial loops#326
pellet wants to merge 2 commits into
NeuroTechX:masterfrom
pellet:feat/realtime-frame-pacing

Conversation

@pellet
Copy link
Copy Markdown
Collaborator

@pellet pellet commented Jun 5, 2026

Encapsulate high priority settings into high_priority_section() context manager function in eegnb/utils/realtime.py that raises three OS settings on entry and restores them on exit:

  • Scheduler tick: timeBeginPeriod(1) drops Windows default 15.625 ms tick to 1 ms, preventing time.sleep from locking a 120 Hz / 8.33 ms loop to half-rate and dropping every other frame (Windows-only; Linux/macOS already run a 1 ms or finer tick).
  • Process priority: core.rush(True) -> HIGH_PRIORITY_CLASS.
  • Python GC: gc.disable() suspends the generational collector.

pellet added 2 commits June 5, 2026 19:02
Add high_priority_section() context manager in eegnb/utils/realtime.py
that raises three OS settings on entry and restores them on exit:

- Scheduler tick: timeBeginPeriod(1) drops Windows default 15.625 ms tick
  to 1 ms, preventing time.sleep from locking a 120 Hz / 8.33 ms loop to
  half-rate and dropping every other frame (Windows-only; Linux/macOS already
  run a 1 ms or finer tick).
- Process priority: core.rush(True) -> HIGH_PRIORITY_CLASS.
- Python GC: gc.disable() suspends the generational collector.

Wire _run_trial_loop through the context manager, replacing the inline
core.rush/gc.disable/try-finally block in run(). BlockExperiment gets
frame-pacing automatically since it calls _run_trial_loop directly.
@pellet pellet marked this pull request as ready for review June 5, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant