Commit Graph
18 Commits
Author SHA1 Message Date
Karoy Lorentey c9ca59fbb9 [PersistentCollections] Improved storage representation
- Switch to using `ManagedBuffer` to represent node storage. This has
  useful performance benefits, but it significantly complicates access
  to node data. We no longer have direct access to the underlying raw
  storage: everything needs to go through closures passed to
  `ManagedBuffer.withUnsafeMutablePointers`.

- Introduce `struct _Node` and `struct _Node.UnsafeHandle` to
  represent a (strong) reference to a hash tree node, and a
  convenient handle for node storage, respectively. Use these instead
  of directly accessing the ManagedBuffer object, whenever feasible.

- Implement separate paths for in-place mutations vs copy-on-write
  operation, optimizing both flavors.

- Go to great lengths to eliminate unnecessary retain-release traffic,
  whenever possible.

- Push subtree counts into parent nodes by moving the corresponding
  field from the node header into the `_Node` struct. (This results in
  a cool ~20x speedup for jumping around in the tree by integer
  offsets.)

- Implement a type-punned empty root singleton, to allow creating
  empty trees without allocating anything.
2022-09-13 23:48:54 -07:00
Karoy Lorentey 3441a48045 [PersistentDictionary] rootNode → root 2022-09-12 12:47:04 -07:00
Karoy Lorentey 3bc9b42739 [PersistentCollections] Standard invariant checks 2022-09-12 12:47:04 -07:00
Karoy Lorentey ca19ecb5b3 [PersistentDictionary] Don’t copy collision node contents into arrays 2022-09-12 12:47:04 -07:00
Karoy Lorentey afdb471af7 [PersistentCollections] “trie”, “subNode” → “child”, “data” → “item”
Also, replace the use of the word “trie” with “prefix trie” (or “hash tree”) throughout the documentation & comments.
2022-09-12 12:47:04 -07:00
Karoy Lorentey 14f90620c8 [PersistentCollections] Introduce _Bucket, _Bitmap, _HashPath, and _HashValue
These provide nicer tools for slicing up hash values and dealing with node bitmaps.

_Bucket is a logical entry in the hash table inside a node.
_Bitmap is a set of bucket values, represented by a bitset.
_HashPath facilitates slicing up a hash value into a series of bucket values.
_HashValue represents a hash value.

This is still just mostly superficial refactoring, with little to no functional changes.
2022-09-09 00:47:10 -07:00
Karoy LorenteyandMichael Steindorfer aa428d0489 Update spelling of publication dates
Co-authored-by: Michael Steindorfer <michael@steindorfer.name>
2022-09-08 16:04:18 -07:00
Karoy Lorentey 750559ea9e [PersistentDictionary] PersistentDictionaryIndex → PersistentDictionary.Index 2022-09-08 00:55:48 -07:00
Karoy Lorentey 6f93a628e8 [PersistentDictionary] BitmapIndexedDictionaryNode → PersistentDictionary._ Node, Header → _NodeHeader
Also move Capacity, Bitmap under _NodeHeader.

Start thematically organizing _Node members.
2022-09-07 21:06:19 -07:00
Karoy Lorentey 2597ff23cd [PersistentDictionary] Apply leading underscore rule to common functions 2022-09-07 21:06:19 -07:00
Karoy Lorentey 7e78002909 [PersistentCollections] Move BitmapSmokeTests into its own file 2022-09-07 19:36:15 -07:00
Karoy Lorentey 1a4993dfda [PersistentCollections] Reformat
Follow the Standard Library coding style:

- Hard 80 character line limit
- Use two spaces as the indentation unit
- Overlong lines broken up by adding line breaks at the following places
    1. After opening delimiters & before closing delimiters
    2. Between each item in a list
    3. Extracting subexpressions etc as needed
2022-09-07 19:16:41 -07:00
Michael Steindorfer fbb8aeda08 [Capsule] Remove non-applicable tests 2022-09-06 21:01:42 +02:00
Michael Steindorfer f930801d37 [Capsule] Expand index(forKey:) tests 2022-09-06 20:40:28 +02:00
Michael Steindorfer 031b762053 [Capsule] Fix test case argument label
Necessary due to removal of unchecked initializer variants.
2022-09-06 18:57:10 +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