-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved to constant-time event cancellation
The previous cancel relied on a naive linear search to find events to cancel. This provided a simple and robust solution that avoided issues with in-flight events. Achieving constant-time cancellation required two modifications: - Use doubly-linked list for queue - Encode event addresses in the event id Encoding the event addresses turned out to be a bit tricky. The equeue library supports cancelling events after they have been dispatched. This used an incrementing counter to obtain pseudo- unique ids. To fit everything in a single int, the event address is stored as an offset from the equeue's memory region. A seperate counter is used for each allocated chunk, taking advantage of the non-coalescing nature of the underlying allocator. Together these are ored to obtain a unique id that can be decoded to obtain the underlying event. Notable performance impact (make prof): equeue_cancel_many_prof: 132 cycles (+75%) equeue_alloc_many_size_prof: 56000 bytes (-12%) equeue_alloc_fragmented_size_prof: 56000 bytes (-12%)
- Loading branch information
Showing
3 changed files
with
71 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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