New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Heap] Performance tweaks #78
Commits on Aug 7, 2021
Commits on Aug 8, 2021
-
[docs] Use a stable link to the Atkinson article
(The original link was pointing to course materials at a random university.)
-
-
Revert "[Heap] Don't always inline large functions"
This reverts commit 07ffd65.
-
-
Commits on Aug 12, 2021
-
[Heap] Precalculate levels for each offset
`_Node` is a new struct that consists of a storage offset (the old index) along with its level in the tree. The level can be incrementally calculated, saving some time vs counting bits whenever it's needed.
-
[Heap] Switch to using unsafe buffer pointers
Introduce `Heap._UnsafeHandle` (a thin wrapper around an unsafe buffer pointer) and rebase most heap algorithms on top of that instead of array operations. This simplifies things by reducing (hopefully) unnecessary index validation, resulting in some measurable performance improvements.
-
[Heap] Stop force-inlining bubbleUp; mark it releasenone
Not inlining such a large function speeds things up by leaving some headroom for the optimizer to make better inlining decisions elsewhere. (Force inlining this resulted in the compiler not inlining the closure passed to `_update` instead, which isn't a great tradeoff. To speed things up, mark `bubbleUp` with `@_effects(releasenone)`. This may be questionable (because it calls `Element.<`), but it results in better codegen, making `insert` match the performance of `std::priority_queue`.
Commits on Aug 13, 2021
Commits on Aug 16, 2021
-
-
[Heap] Perf pass on trickleDown code paths
This improves popMin/popMax (and the sequence initializer) by reviewing trickleDown and optimizing things: - Replace swapAt with a scheme where we keep a hold in the storage buffer - Slightly shorten min/max dependency chain in primary sink loop In exchange, we get even less readable code.
Commits on Aug 17, 2021
-
[Heap] bubbleUp: remove @_effects attribute
This reintroduces retain/release operations for the empty array until apple/swift#38898 lands. Mitigate the performance costs of this by refactoring code to reduce the size of the inlined bubbleUpMin/Max invocations.
-