Skip to content

scheduler: make closed-stream cleanup expiry-driven - #265

Merged
anmonteiro merged 1 commit into
masterfrom
fix/closed-stream-cleanup-expiry-queue
Mar 9, 2026
Merged

scheduler: make closed-stream cleanup expiry-driven#265
anmonteiro merged 1 commit into
masterfrom
fix/closed-stream-cleanup-expiry-queue

Conversation

@anmonteiro

Copy link
Copy Markdown
Owner

Summary

  • decouple closed-stream cleanup from write-path polling
  • replace per-poll marked_for_removal table scans with an expiry queue keyed by stream id
  • keep cleanup work proportional to actually-expired entries on each scheduler tick
  • tick cleanup in both client/server read polling paths
  • add regression test showing closed streams are reaped even without next_write_operation polling

Details

Previously, TTL decrement/removal for closed streams happened inside Scheduler.flush (write scheduling), so idle/read-mostly connections could retain closed streams indefinitely if writes were not polled.

This PR introduces:

  • cleanup_epoch + cleanup_queue on scheduler root
  • mark_for_removal enqueues stream_id -> expires_at
  • tick_closed_streams advances epoch and pops expired entries only

Validation

  • dune runtest --no-buffer passes
  • includes new test: closed stream cleanup does not depend on write polling

@anmonteiro
anmonteiro force-pushed the fix/closed-stream-cleanup-expiry-queue branch from 4ff42b8 to b939202 Compare March 9, 2026 03:31
@anmonteiro
anmonteiro force-pushed the fix/closed-stream-cleanup-expiry-queue branch from b939202 to 8a8eda1 Compare March 9, 2026 03:37
@anmonteiro
anmonteiro merged commit d93edba into master Mar 9, 2026
6 checks passed
@anmonteiro
anmonteiro deleted the fix/closed-stream-cleanup-expiry-queue branch March 9, 2026 03:40
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