Skip to content

Jrmales/modal ps ds restart hardening#30

Merged
jaredmales merged 2 commits intodevfrom
jrmales/modalPSDs-restart-hardening
Mar 22, 2026
Merged

Jrmales/modal ps ds restart hardening#30
jaredmales merged 2 commits intodevfrom
jrmales/modalPSDs-restart-hardening

Conversation

@jaredmales
Copy link
Copy Markdown
Owner

This work was performed by Codex (GPT-5) in response to the prompt: "after reviewing agent_context.md, please analyze the app modalPSDs (app/modalPSDs) looking for data races, restart bugs, memory management problems, etc. This app routinely crashes when the inputs resize or are recreated."

Summary

This PR adds a fixed-size SPSC specialization for mx::sigproc::circularBufferIndex to support low-latency, restart-safe producer/consumer handoff for modalPSDs.

The new specialization is intended for:

  • fixed-capacity operation after maxEntries()
  • one producer thread
  • one consumer thread
  • atomic publication of ring-buffer metadata
  • snapshot/load-style access to coherent logical windows

Motivation

modalPSDs needed a way to keep its steady-state source-pointer buffering zero-copy and low-overhead while still avoiding the unsynchronized push_back()/growth behavior and metadata races present in the generic dynamic circular-buffer path.

This PR introduces a dedicated fixed-size SPSC mode rather than changing behavior for existing users of the legacy circular buffer.

Scope

The new specialization adds:

  • fixed-size storage setup
  • atomic latest / nextEntry / validEntries / mono publication state
  • snapshot metadata describing the readable region
  • validated sequence-load helpers for coherent consumer-side reads

Existing non-fixed-size users remain on the legacy implementation.

Validation

This change was validated through the downstream modalPSDs integration and test pass in MagAO-X.

Affected Files

  • include/sigproc/circularBuffer.hpp

Follow-Up / Edge Cases

  • The fixed-size specialization is intentionally SPSC-focused, not a general multi-producer/multi-consumer concurrent buffer.
  • Additional direct mxlib unit coverage for the new specialization would still be worthwhile if this API is adopted more broadly.

@jaredmales jaredmales merged commit 60001ab into dev Mar 22, 2026
1 check passed
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