-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify Heap implementation. (#961)
Motivation: Our original Heap implementation used a bunch of static functions in order to make it clear how it related to textbook heap implementations. This was primarily done to ensure that it was easier to see the correctness of the code. However, we've long been satisfied with the correctness of the code, and the Heap is one of the best tested parts of NIO. For this reason, we should be free to refactor it. Given https://bugs.swift.org/browse/SR-10346, we've been given an incentive to do that refactor right now. This is because the Heap is causing repeated CoW operations each time we enqueue new work onto the event loop. That's a substantial performance cost: well worth fixing with a small rewrite. Modifications: - Removed all static funcs from Heap - Rewrote some into instance funcs - Merged the implementation of insert into append. - Added an allocation test to avoid regressing this change. Result: Faster Heap, happier users, sadder textbook authors. (cherry picked from commit f79c7ae)
- Loading branch information
Showing
5 changed files
with
63 additions
and
56 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
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