refactor: remove cancelled counter via O(1) abort removal - #22
Merged
Conversation
The waiter queue was singly-linked with lazy deletion: an aborted waiter could not be unlinked in O(1), so it stayed in the queue as a tombstone and a `cancelled` counter tracked how many were pending. release() walked past them and awaiting() subtracted them. When aborts outpaced releases, both the queue and `cancelled` grew without bound. Make LinkedList doubly-linked (prev pointer + O(1) remove(node)) so abort unlinks its own node immediately. This deletes the `cancelled` counter, the `waiter.cancelled` flag, the skip-loop in release(), and the subtraction in awaiting(). The queue now holds only live waiters, so awaiting() === size(). Public API unchanged; all 17 tests pass at 100% coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Kikobeats
force-pushed
the
refactor/o1-abort-removal
branch
from
July 13, 2026 07:53
3cbc9d9 to
a0b8e28
Compare
coverallsapp/github-action fails the whole job when the coverage upload errors (e.g. Coveralls down with a 504). fail-on-error: false makes the step log the error and exit 0, so a coverage-service outage no longer breaks CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The waiter queue was singly-linked with lazy deletion: an aborted waiter could not be unlinked in O(1), so it stayed in the queue as a tombstone and a
cancelledcounter tracked how many were pending. release() walked past them and awaiting() subtracted them. When aborts outpaced releases, both the queue andcancelledgrew without bound.Make LinkedList doubly-linked (prev pointer + O(1) remove(node)) so abort unlinks its own node immediately. This deletes the
cancelledcounter, thewaiter.cancelledflag, the skip-loop in release(), and the subtraction in awaiting(). The queue now holds only live waiters, so awaiting() === size().Public API unchanged; all 17 tests pass at 100% coverage.
Note
Medium Risk
Changes concurrency wait-queue behavior (abort, release, awaiting) though the public API and tests are unchanged; incorrect unlinking could affect slot handoff order or counts.
Overview
Lock queue internals are reworked so aborted waiters are removed from the queue immediately instead of staying as tombstones.
The internal
LinkedListis now doubly-linked (prev+remove(node)),enqueuereturns the node, andAbortSignalhandlers callqueue.remove(node). That drops thecancelledcounter, per-waitercancelledflags, therelease()loop that skipped dead entries, and theawaiting()adjustment—awaiting()now matches live queue length only.release()only dequeues the next live waiter.CI sets
fail-on-error: falseon the Coveralls step so coverage upload failures do not fail the workflow. A cancel test comment is updated to match the new behavior.Reviewed by Cursor Bugbot for commit f47ca74. Bugbot is set up for automated code reviews on this repo. Configure here.