Skip to content

Bound stale semaphore notifications and handle overflow after publication #37

Description

@prezaei

Reviewed source: e0fd9c3886d6396d2a951523d45039d3ea3ad469. Reproductions were run directly on macOS ARM64 with .NET 10.0.12.

Publisher.cs:58, Subscriber.cs:89

Every successful publish posts a permit, but successful immediate reads do not consume one. After 100,000 successful enqueue/dequeue pairs, the empty queue still had exactly 100,000 permits. A later empty blocking read must work through these stale notifications. At the platform semaphore limit, Release can throw after the message is already committed, making enqueue outcome ambiguous. Overflow was not exercised in this audit.

This is a promising performance target, but do not blindly skip posts or add a native wait to every successful read: the former can lose wakeups and the latter adds a syscall to the fast path. A bounded/coalesced notification design needs proof for multiple publishers/readers and mixed versions. Overflow handling should acknowledge that the message is already committed.

Acceptance criteria

Prevent unbounded stale-notification work and avoid reporting a committed message as an enqueue failure solely because the semaphore count is full. Prove wakeup behavior with multiple publishers/subscribers and existing participants; benchmark burst-to-idle traffic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions