Commit graph

427 commits

Author SHA1 Message Date
Orion Henry
1c61986d33 clippy and fmt 2022-02-24 15:48:48 -05:00
David Pollak
bde0a6fbf6 Cleaned up some warnings and errors running against Rust 1.58.1 2022-02-24 15:20:48 -05:00
Andrew Jeffery
68491b66a3 Move some backend functions to traversal 2022-02-18 08:47:27 -08:00
Andrew Jeffery
3cf2044a07 Move vector clock implementation to new module 2022-02-18 08:47:27 -08:00
Andrew Jeffery
7991369dfa Add semicolon 2022-02-18 08:47:27 -08:00
Andrew Jeffery
729e6ccbce Document vector clock usage 2022-02-18 08:47:27 -08:00
Andrew Jeffery
907df09b6a Use queue when getting vector clocks to do BFS 2022-02-18 08:47:27 -08:00
Andrew Jeffery
1a8f5c159f Cleanup code 2022-02-18 08:47:27 -08:00
Andrew Jeffery
a654e2b548 Tidy imports 2022-02-18 08:47:27 -08:00
Andrew Jeffery
e57e839022 Just use vector clocks in retain 2022-02-18 08:47:27 -08:00
Andrew Jeffery
7ceee4957e Print length of may_find 2022-02-18 08:47:27 -08:00
Andrew Jeffery
1cd32a295f Use clock in filter_changes 2022-02-18 08:47:27 -08:00
Andrew Jeffery
f5d9d3a105 Add clocks cache 2022-02-18 08:47:27 -08:00
Andrew Jeffery
abef4dac8c Don't clone actor id 2022-02-18 08:47:27 -08:00
Andrew Jeffery
601ba7a50c Use vector clock for slow path 2022-02-18 08:47:27 -08:00
Andrew Jeffery
a76428dfc1 Use vector clock for get_changes
When get_changes has to fall back to get_changes_slow it can be very
slow, having to traverse the entire graph but also suffers from having
to keep track of the seen dependencies in a hashset (which rather
thrashes the memory).

Instead, if we calculate the vector clock for each hash we are given and
take the maximum over those then we can see which changes we need more
easily. In the worst case this still suffers from going through the
entire graph but this could be cached for later use. The worst case is
now when an actor makes a single change right at the start of the
history. In this case we have to go through the entire graph just to
find it and ensure that it is in the closure.
2022-02-18 08:47:27 -08:00
alexjg
e72571962b
Correctly sort actor IDs when encoding changes (#241)
The javascript implementation of automerge sorts actor IDs
lexicographically when encoding changes. We were sorting actor IDs in
the order the appear in the change we're encoding. This meant that the
index that we assigned to operations in the encoded change was different
to that which the javascript implementation assigns, resulting in
mismatched head errors as the hashes we created did not match the
javascript implementation.

This change fixes the issue by sorting actor IDs lexicographically. We
make a pass over the operations in the change before encoding to collect
the actor IDs and sort them. This means we no longer need to pass a
mutable `Vec<ActorId>` to the various encode functions, which cleans
things up a little.

Fixes #240
2021-10-17 11:58:15 +01:00
Alex Good
9a421f1f79
Update interop tests to automerge 1.0.1-preview.5
This resulted in one failing test which was due to the pending_changes
we report for a patch being incorrectly calculated from missing
dependencies. I've added a test for this failure and fixed it, interop
tests now pass.
2021-10-14 13:40:16 +01:00
Alex Good
d279819bfc Update to rand 0.8 2021-10-11 19:48:33 +01:00
Andrew Jeffery
ba32c07fc4 Fixup apply_local_change doc link 2021-10-10 16:51:56 +01:00
Alex Good
5a26f8fcd1 Add missing licenses 2021-09-23 23:41:51 +01:00
Andrew Jeffery
3c786b26a8
Make apply_local_change return ref to change (#231)
* Make apply_local_change return ref to change

* Remove mut for change

* Document apply_local_changes
2021-07-29 17:41:56 +01:00
Andrew Jeffery
f14697cb61
Add size_hint for expanded op iterator (#219) 2021-07-15 11:52:07 +01:00
Andrew Jeffery
9f554252d0
Use tinyvec for actor id (#179)
* Use tinyvec for actor id

Most of the time users will not be using their own identifiers and so
use random uuids. These can fit nicely on the stack for a speedup.
TinyVec allows us to capture this mostly stack, sometimes heap
behaviour.

* Use git version of tinyvec for arbitrary
2021-07-15 10:18:07 +01:00
Andrew Jeffery
990d2bb4f3
Reduce deflate compression on the hot path (#186) 2021-07-13 11:04:39 +01:00
Andrew Jeffery
a033e4ed05
load: Reduce intermediate collects and use iterators more (#208) 2021-07-05 17:27:55 +01:00
Andrew Jeffery
3ca5c68151
load: Don't generate a patch that will just be dropped (#209) 2021-07-05 17:22:23 +01:00
Andrew Jeffery
64114b901d
Check heads when decoding a document (#207) 2021-07-05 17:22:06 +01:00
Orion Henry
3db6f9ef13
Fix Clippy issues, broken tests, formatting issues (#188)
* fix clippy errors

* Bump travis nvm version

* Add smol_str arbitrary

* Fix Err prefix clippy error

* Fix clippy needless-borrow

* Ensure SortedVec sorts on deserialize

Co-authored-by: Andrew Jeffery <dev@jeffas.io>
2021-06-28 13:20:21 +01:00
Andrew Jeffery
14d92e513c
Stop non-empty needs repeating messages (#193) 2021-06-27 14:59:23 +01:00
Vedant Roy
ca638691d0 Tests pass after rebase 2021-06-25 11:06:25 -07:00
Vedant Roy
aecfcf2c87 Rebase + clippy 2021-06-25 11:06:25 -07:00
Vedant Roy
338ec28992 Satisfy clippy 2021-06-25 11:06:25 -07:00
Vedant Roy
b82463bb87 Tests pass 2021-06-25 11:06:25 -07:00
Vedant Roy
a3a9d0b1fb condense_insert_ops failing 2021-06-25 11:06:25 -07:00
Vedant Roy
9353ae40b2 Remove F32 2021-06-25 11:06:25 -07:00
Vedant Roy
d35fc961e9 Ensure values have same type when constructing MultiElementInsert 2021-06-25 11:06:25 -07:00
Andrew Jeffery
08fd039eb3
Reduce use of new features to build on older Rusts (#184) 2021-06-25 16:03:13 +01:00
Andrew Jeffery
fe5a9a816d
Cleanup ColumnOp in backend and use sort_unstable (#187)
* Use sort_unstable_by for sorting columns

* Use ExpandedOp directly in ColumnEncoder
2021-06-25 14:20:34 +01:00
Andrew Jeffery
1383068064
Backend rearrangements (#177)
* Add SortedVec struct to ensure preds are sorted

* Add into_iter for sortedvec

* Specify capacity of bytes

* Pass docops by value

* Use Cow for operation keys

* More preallocation

* Use swap remove instead of remove to avoid O(n)

* Use default compression level for better balance of performance

* Remove result for incorporate_new_op

* Import actor once

* Allocate for the new value too in LiteralRun

The literalrun will finish with pushing the new `value` onto the vec so
we can allocate for that from the start.

* Set capacity of rangemap

* Preallocate data
2021-06-19 17:26:56 +01:00
Andrew Jeffery
987263b25d
Add SortedVec struct to ensure preds are sorted (#176)
* Add SortedVec struct to ensure preds are sorted

* Add into_iter for sortedvec
2021-06-19 17:25:25 +01:00
Andrew Jeffery
fc1b8f87fb
Use SmolStr in place of String (#182)
Most of the strings are small and so fit nicely in a SmolStr. When they
don't it just reverts to using a normal String.
2021-06-19 16:28:51 +01:00
Andrew Jeffery
ff8b8613d5
Flatten objtype (#175)
* Flatten object type

* Use separate construct functions

* Use separate gen_*_diff functions

* Remove maptype and seqtype from Diffs

* Preallocate ops in new_map_or_table

* More preallocations
2021-06-17 20:06:10 +01:00
Andrew Jeffery
79239cc6a4
Improve load performance when no cursors are present (#171)
* Add save and load to benchmarks

* Improve load performance when no cursors are found
2021-06-16 11:50:49 +01:00
Andrew Jeffery
8b3938c2e7
Rename UncompressedChange to Change (#173)
It wasn't really uncompressed as we have compressed and uncompressed
changes in the backend. It is just not encoded into the binary format.
The module separation (protocol vs backend) should help with the
distinction.
2021-06-16 11:50:26 +01:00
Andrew Jeffery
71b59dea68
Set levels for instrument (#164) 2021-06-14 23:34:35 +01:00
Orion Henry
647b8d2af2 fix deflate column decode order 2021-06-12 15:01:38 -07:00
Orion Henry
d8a56d966e added binary search to doc decode for big speedup 2021-05-29 13:34:03 -07:00
Andrew Jeffery
e98ed15582 Sort predecessors during encoding 2021-05-25 11:29:25 +01:00
Orion Henry
72d15bfe99 a few things broke in the merge 2021-05-24 16:27:05 -04:00