Commit Graph
26 Commits
Author SHA1 Message Date
Karoy Lorentey 1a87233bcd [PersistentCollections] Review & update benchmarks 2022-09-07 17:35:59 -07:00
Karoy Lorentey de5fad7477 Merge pull request #31 from msteindorfer/capsule-collections
Incubate persistent data structures
2022-09-07 09:18:23 -07:00
Michael Steindorfer e2f53441d6 [Capsule] Add subscript(position:) benchmarks 2022-09-06 20:39:38 +02:00
Michael Steindorfer 49283d3251 [Capsule] Remove unchecked variant of initializer 2022-09-06 16:37:23 +02:00
Michael Steindorfer 26b97f95d2 [Capsule] Unify insertion/deletion methods
Note, always tracking discardable result negatively impacts batch
use cases.
2022-09-06 16:11:17 +02:00
Michael Steindorfer 5bc17ffe84 [Capsule] Rename package to PersistentCollections 2022-09-06 13:22:10 +02:00
Michael Steindorfer f6fe3c0658 [Capsule] Add init(uncheckedUniqueKeysWithValues:) benchmark
Further add missing items to the benchmark library.
2022-09-06 09:38:36 +02:00
Michael Steindorfer 8bc5e20b29 [Capsule] Enable Keys and Values view benchmarks 2022-09-05 20:53:41 +02:00
Michael Steindorfer afcd915044 [Capsule] Add persistent dictionary index benchmarks 2022-09-02 09:00:52 +02:00
Karoy Lorentey c82261a529 [Deque] Add direct benchmarks for indexing subscript’s _modify accessor 2022-08-31 14:59:50 -07:00
Karoy Lorentey b9d91f4a9a Remove benchmarking data 2022-08-17 22:58:37 -07:00
Karoy Lorentey 3bf91b1ee4 Remove hash lookups while filtering 2022-08-17 22:57:37 -07:00
Konrad `ktoso` Malawski f56388e4f7 =OrderedSet.filter Attempt to optimize filter impl 2022-08-18 10:28:20 +09:00
Michael Steindorfer 92d07b3910 [Capsule] Add [COW] subscript, remove existing benchmark 2022-08-09 17:20:29 +02:00
Michael Steindorfer fc60fae4d7 [Capsule] Rename HashMap to PersistentDictionary 2022-08-09 17:20:28 +02:00
Michael Steindorfer f956009ac2 [Capsule] Add [COW] subscript, insert benchmark 2022-08-09 17:20:28 +02:00
Michael Steindorfer 5fad00e87b [Capsule] Remove reserveCapacity test since it is not supported 2022-08-09 17:20:28 +02:00
Michael Steindorfer 0f0c0bdc90 [Capsule] Pin type to Capsule hash-map 2022-08-09 17:20:28 +02:00
Michael Steindorfer 1ffd819a0e [Capsule] Draft benchmark configuration 2022-08-09 17:20:28 +02:00
Michael Steindorfer e28f675e3f [Capsule] Copy DictionaryBenchmark and add some Dictionary API 2022-08-09 17:20:28 +02:00
Karoy Lorentey 0d1ca3240c Stop depending on swift-collections-benchmark (#86)
* Stop depending on swift-collections-benchmark

Instead, move the benchmark suite into its own private nested package, under `Benchmarks/`.

The recommended way to build & run benchmarks is via the `Utils/run-benchmarks.sh` script, which continues to work as before with this change.

* Delete top-level Package.resolved file
2021-08-19 11:42:14 -07:00
Karoy Lorentey f73d5e95a8 Add reference benchmarks for bit vector implementations (#79)
* [benchmark] Reorganize C++/Foundation benchmarks into separate files

* [benchmark] Add reference benchmarks for std::vector<bool> and CFBitVector

* Fix thinko breaking non-Darwin builds
2021-08-13 14:14:26 -07:00
Karoy Lorentey cc69069676 [benchmark] Review and extend Heap benchmarks (#76)
* [benchmark] Review and extend Heap benchmarks

* FoundationBenchmark only supports Apple platforms

* Rewrite CFBinaryHeap benchmarks in pure Swift
2021-08-07 14:41:02 -07:00
940c963bc4 Add a min-max heap implementation that can be used to back a priority queue (#61)
* Add PriorityQueue implementation built on top of a MinMaxHeap

* Merge MinMaxHeap into PriorityQueue

* Add `unordered` read-only view into underlying heap

* Start filling in PriorityQueue benchmarks

* Implement our own swapAt()

storage.swapAt exhibits excessive allocations

* Rename _delete(at:) to _remove(at:)

* Rename removeMin/removeMax -> popMin/popMax

* Use magic values 1, 2 to refer to the items in the first max level

Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>

* Specify logarithmic complexities as "O(log `count`) / 2" instead of "O(log n)"

Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>

* Clarify logic in popMax

* Simplify logic in _remove(at:)

* Move the bounds checking into the various index computation methods

They will all now return `nil` for invalid indices.

* Floyd's heap construction algorithm should start from count/2 - 1

* Add ObjC wrapper around CFBinaryHeap to benchmarks

* Fix benchmarks that broke because of renames

* Add removeMin/removeMax

* Make _minMaxHeapIsMinLevel an instance method

* Split _indexOfChildOrGrandchild(of:sortedUsing:) into two separate functions

There is a large performance cost with passing a predicate function.

* Defer comparing children when determining largest/smallest descendant

If the given index has 4 grandchildren, we can skip comparing the children.

* Added an iterator of the min and max views to the priority queue

* seperated iterator implementation into a new file

* Use renamed popMin/Max in Iterator instead of removeMin/Max

* Fix code formatting

Indentation of 2 spaces and 80 char column width

* Add sequence initializer

* Fix code formatting in benchmarks

* Fix benchmark names

* Remove init from Collection

This should already be handled by the init from Sequence

* Add conformance to ExpressibleByArrayLiteral

* Move ExpressibleByArrayLiteral conformance to separate file

* Update PriorityQueue's CMakeLists.txt

* Make ascending and descending iterators public

* Inline ALL THE THINGS!

* Iterative instead of recursive implementation, @inline(__always) a couple more critical functions.

* Address PR feedback, thanks!

* Check invariants on insertion and deletion

* Minor code formatting cleanup

* Add copyright header to test file

* Fix missing empty line

* Add naïve implementation of insert(contentsOf:)

* Add documentation on complexity of init<S:Sequence>(_:)

* Cite source paper in documentation

* Rename PriorityQueue -> MinMaxHeap

We'll be reintroducing the PriorityQueue type as a wrapper.

* Mark insert(contentsOf:) as inlinable

This results in ~10x speedup in my initial tests.

* Rename argument label "startingAt" -> "elementAt"

These functions used to be recursive, so "startingAt" made sense.
Now that they're iterative, we should fix the label.

* Remove coefficients from complexity docs

* Make `_minMaxHeapIsMinLevel` take an index instead of a count

* Rename MinMaxHeap -> Heap

* Add documentation for Heap

* Make Heap.Iterator init and direction internal

* Fix reference to queue in documentation

Co-authored-by: Dante Broggi <34220985+Dante-Broggi@users.noreply.github.com>

* Don't wrap integers in CFBinaryHeap benchmark in NSNumber

* Avoid heap allocation altogether

* Add table with performance of operations

* Add heap performance graph

* Apply suggestions from code review

Co-authored-by: Karoy Lorentey <klorentey@apple.com>

* Make _checkInvariants comments a doc comment

* Split Heap.Iterator into two separate views

Adapted from Daryle Walker's (github.com/CTMacUser) suggestions

* Prefix heap storage variable with an underscore

* Update benchmark image

* Fix Sources/PriorityQueueModule/CMakeLists.txt

Heap+Iterator.swift was renamed to Heap+OrderedViews.swift

Co-authored-by: Karoy Lorentey <klorentey@apple.com>

* CFBinaryHeap is only available on Darwin

* CFBinaryHeap is only available on Darwin

* CFBinaryHeap is only available on Darwin

Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>
Co-authored-by: Amanuel Ephem <amanuelephrem776@gmail.com>
Co-authored-by: Joakim Hassila <joj@mac.com>
Co-authored-by: Dante Broggi <34220985+Dante-Broggi@users.noreply.github.com>
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2021-08-06 22:21:23 -07:00
Scott Perry 7b37f7892b Add benchmarks and clean up headerdoc 2021-04-05 20:57:32 -07:00
Karoy Lorentey a2bcac435f Initial import.
Introduce OrderedCollections module
2021-04-05 09:41:00 -07:00