Skip to content
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

Merged
merged 16 commits into from Aug 17, 2021
Merged

[Heap] Performance tweaks #78

merged 16 commits into from Aug 17, 2021

Commits on Aug 7, 2021

  1. Copy the full SHA
    07ffd65 View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2021

  1. [docs] Use a stable link to the Atkinson article

    (The original link was pointing to course materials at a random university.)
    lorentey committed Aug 8, 2021
    Copy the full SHA
    4dc71f6 View commit details
    Browse the repository at this point in the history
  2. Remove stray import

    lorentey committed Aug 8, 2021
    Copy the full SHA
    c41a7b7 View commit details
    Browse the repository at this point in the history
  3. Revert "[Heap] Don't always inline large functions"

    This reverts commit 07ffd65.
    lorentey committed Aug 8, 2021
    Copy the full SHA
    fb3980b View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    3c4be2f View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    013ed20 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2021

  1. [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.
    lorentey committed Aug 12, 2021
    Copy the full SHA
    891eb7a View commit details
    Browse the repository at this point in the history
  2. [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.
    lorentey committed Aug 12, 2021
    Copy the full SHA
    6822d83 View commit details
    Browse the repository at this point in the history
  3. [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`.
    lorentey committed Aug 12, 2021
    Copy the full SHA
    612c391 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2021

  1. [Heap] Rework removals

    lorentey committed Aug 13, 2021
    Copy the full SHA
    454da8f View commit details
    Browse the repository at this point in the history
  2. [Heap] Remove dead code

    lorentey committed Aug 13, 2021
    Copy the full SHA
    26d0f2d View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2021

  1. Copy the full SHA
    1725165 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    362b62e View commit details
    Browse the repository at this point in the history
  3. [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.
    lorentey committed Aug 16, 2021
    Copy the full SHA
    c4282ca View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2021

  1. [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.
    lorentey committed Aug 17, 2021
    Copy the full SHA
    26d515b View commit details
    Browse the repository at this point in the history
  2. [Heap] Finetune Heap.insert

    lorentey committed Aug 17, 2021
    Copy the full SHA
    303e199 View commit details
    Browse the repository at this point in the history