Commit graph

123 commits

Author SHA1 Message Date
Zixuan Chen
17571ab6e0
Add size benchmark example (#276)
* test: add size bench example

* chore: update lock file
2024-02-28 21:59:20 +08:00
Zixuan Chen
f648b353ad
chore: upgrade rust crates 2024-02-16 11:30:56 +08:00
Zixuan Chen
0bcc3bd56d
chore: upgrade wasm-bindgen to 0.2.90 (#262) 2024-01-29 22:40:33 +08:00
Leon Zhao
f6cc5da0f1
refactor: Optimizing Encoding Representation for Child Container Creation to Reduce Document Size (#247)
* refactor: encoding container id

* fix: container indexing when merged ops in encoding

* chore: add compress encode size for draw example

* fix: do not need cids in encoding

* chore: change name containerIdx to containerType in encoding
2024-01-22 12:19:09 +08:00
Zixuan Chen
5f1353791d
Remove txn abort and reduce mem usage (#240)
* refactor: rm txn.abort and related undo behavior

* perf: simplify richtext state when there is not styles

* perf: reduce text cost when there is no style

* chore: refine logs

* perf: remove cid in states to reduce mem overhead

* refactor: reduce mem overhead by using a compacter mapvalue

* refactor: rm the box inside richtext state
2024-01-08 17:29:11 +08:00
Zixuan Chen
a30abf7af1
chore: upgrade debug-log to fix type issue 2024-01-05 16:07:47 +08:00
Zixuan Chen
aaec64a503
Update debug-log (#236)
* chore: use new version of debug-log

* fix: rm group_end
2024-01-05 12:12:04 +08:00
Zixuan Chen
a6be7d2ea6
refactor: make InternalString an internal struct (#233) 2024-01-02 20:11:22 +08:00
Zixuan Chen
bc27a47531
feat: stabilizing encoding (#219)
This PR implements a new encode schema that is more extendible and more compact. It’s also simpler and takes less binary size and maintaining effort. It is inspired by the [Automerge Encoding Format](https://automerge.org/automerge-binary-format-spec/).

The main motivation is the extensibility. When we integrate a new CRDT algorithm, we don’t want to make a breaking change to the encoding or keep multiple versions of the encoding schema in the code, as it will make our WASM size much larger. We need a stable and extendible encoding schema for our v1.0 version.

This PR also exposes the ops that compose the current container state. For example, now you can make a query about which operation a certain character quickly. This behavior is required in the new snapshot encoding, so it’s included in this PR.

# Encoding Schema

## Header

The header has 22 bytes.

- (0-4 bytes) Magic Bytes: The encoding starts with `loro` as magic bytes.
- (4-20 bytes) Checksum: MD5 checksum of the encoded data, including the header starting from 20th bytes. The checksum is encoded as a 16-byte array. The `checksum` and `magic bytes` fields are trimmed when calculating the checksum.
- (20-21 bytes) Encoding Method (2 bytes, big endian): Multiple encoding methods are available for a specific encoding version.

## Encode Mode: Updates

In this approach, only ops, specifically their historical record, are encoded, while document states are excluded.

Like Automerge's format, we employ columnar encoding for operations and changes.

Previously, operations were ordered by their Operation ID (OpId) before columnar encoding. However, sorting operations based on their respective containers initially enhance compression potential.

## Encode Mode: Snapshot

This mode simultaneously captures document state and historical data. Upon importing a snapshot into a new document, initialization occurs directly from the snapshot, bypassing the need for CRDT-based recalculations.

Unlike previous snapshot encoding methods, the current binary output in snapshot mode is compatible with the updates mode. This enhances the efficiency of importing snapshots into non-empty documents, where initialization via snapshot is infeasible. 

Additionally, when feasible, we leverage the sequence of operations to construct state snapshots. In CRDTs, deducing the specific ops constituting the current container state is feasible. These ops are tagged in relation to the container, facilitating direct state reconstruction from them. This approach, pioneered by Automerge, significantly improves compression efficiency.
2024-01-02 17:03:24 +08:00
Zixuan Chen
727b5c2518
Add benchmark utils that simulate drawing workflow (#229)
* chore: add benchmark utils that simulate drawing workflow

* chore: use markdown as table default style

* chore: init sheet simulating
2023-12-28 18:00:34 +08:00
Zixuan Chen
f4c6b6dce7
refactor: rm compact bytes (#206) 2023-12-05 11:58:09 +08:00
Zixuan Chen
cccb4f3957
perf(wasm): reduce wasm size (#198) 2023-11-29 13:59:39 +08:00
Zixuan Chen
fddcf7a321
chore: publish v0.2.2 with refined doc 2023-11-28 23:23:07 +08:00
Zixuan Chen
cd8be80a6f
docs: refine rust api doc 2023-11-28 23:20:57 +08:00
Zixuan Chen
1eae5ea495
chore: bump loro rust to v0.2.1 2023-11-28 22:22:09 +08:00
Zixuan Chen
22cf71a759
chore: upgrade loro to v0.2.1 2023-11-28 22:18:21 +08:00
Zixuan Chen
564dde7703
chore: publish mvp rust api 2023-11-28 21:29:11 +08:00
Zixuan Chen
6ef1e12d71
chore: rm zerovec 2023-11-28 21:01:01 +08:00
Zixuan Chen
2ad7202e05
Feat-rust-api (#193) 2023-11-28 16:22:43 +08:00
Leon zhao
dd8bf7719e
refactor: rm loro nodejs (#185) 2023-11-21 23:12:05 +08:00
Leon zhao
899270c6de
fix: remove compress feature (#184)
BREAKING CHANGE: encoding schema is changed
2023-11-21 21:48:25 +08:00
Zixuan Chen
7ccfd1e91d
feat: expose version and change inspect api to wasm (#156) 2023-11-05 16:06:34 +08:00
Zixuan Chen
8bd953e396
refactor: extract text chunk (#153) 2023-11-04 20:03:43 +08:00
Zixuan Chen
5b65963104
fix: imported changes were not mergeable (#147)
* fix: imported changes were not mergeable
now the small encoding size is supported in example

* fix: stupid err in richtext checkout

* fix: rle oplog encode err
- support pending changes
- start counters were wrong
2023-11-04 12:23:28 +08:00
Zixuan Chen
da16b8a99d
refactor: use better repr for container id (#144) 2023-11-02 17:13:08 +08:00
Zixuan Chen
a40b5c6e4a
feat: support richtext in wasm & mark text with arbitrary value (#142)
- Support mark text with custom value [LORO-299] Allow users to mark text with custom value #139
- Expose richtext in wasm
2023-11-02 14:20:34 +08:00
Zixuan Chen
a52549ea30
fix: g-btree bug, fixed by upgrade dep 2023-10-31 22:04:43 +08:00
Zixuan Chen
bcf81a45eb
fix: g-btree delete leaf err
upgrade generic-btree
2023-10-31 21:08:07 +08:00
Zixuan Chen
4d87725f32
chore: rm needless package 2023-10-29 22:13:59 +08:00
Zixuan Chen
d942e3d7a2
Feat: Peritext-like rich text support (#123)
* feat: richtext wip

* feat: add insert to style range map wip

* feat: richtext state

* fix: fix style state inserting and style map

* fix: tiny vec merge err

* fix: comment err

* refactor: use new generic-btree & refine impl

* feat: fugue tracker

* feat: tracker

* feat: tracker

* fix: fix a few err in impl

* feat: init richtext content state

* feat: refactor arena

* feat: extract anchor_type info out of style flag

* refactor: state apply op more efficiently
we can now reuse the repr in state and op

* fix: new clippy errors

* refactor: use state chunk as delta item

* refactor: use two op to insert style start and style end

* feat: diff calc

* feat: handler

* fix: tracker checkout err

* fix: pass basic richtext handler tests

* fix: pass handler basic marking tests

* fix: pass all peritext criteria

* feat: snapshot encoding for richtext init

* refactor: replace Text with Richtext

* refacotr: rm text code

* fix: richtext checkout err

* refactor: diff of text and map

* refactor: del span

* refactor: event

* fix: fuzz err

* fix: pass all tests

* fix: fuzz err

* fix: list child cache err

* chore: rm debug code

* fix: encode enhanced err

* fix: encode enchanced

* fix: fix several richtext issue

* fix: richtext anchor err

* chore: rm debug code

* fix: richtext fuzz err

* feat: speedup text snapshot decode

* perf: optimize snapshot encoding

* perf: speed up decode & insert

* fix: fugue span merge err

* perf: speedup delete & id cursor map

* fix: fugue merge err

* chore: update utils

* perf: speedup text insert / del

* fix: cursor cache

* perf: reduce conversion by introducing InsertText

* perf: speed up by refined cursor cache

* chore: update gbtree dep

* refactor(wasm): use quill delta format

* chore: fix warnings
2023-10-29 14:02:13 +08:00
leeeon233
f1adc7d15d chore: use columnar 0.3.2 2023-09-11 14:54:54 +08:00
leeeon233
5b0f3e3f50 feat: update columnar 2023-09-08 08:21:46 +08:00
Zixuan Chen
f208744ec1
feat: encode/decode v2 2023-08-29 15:13:52 +08:00
Zixuan Chen
08beb9f60b chore: rm serde requirement in append-only-bytes 2023-08-04 11:03:57 +08:00
Zixuan Chen
1e736df133
Refactor: rm legacy code (#97)
* refactor: rm legacy code

* chore: rm dead code

* refactor: mv refactored files outside

* refactor: rename files & methods

* chore: rm unused deps

* fix: compact bytes err

* chore: fix ci
2023-07-31 11:49:55 +08:00
Zixuan Chen
86057adb05 fix: make events JsValue
this can avoid memory leak when FinalizationRegistry is unavailable
2023-07-30 20:33:46 +08:00
Zixuan Chen
15be521777 feat: event & wasm 2023-07-29 02:03:51 +08:00
Zixuan Chen
fa13d1d06f fix: list state err
update g-btree to use a get node with Option
return value
2023-07-23 00:11:46 +08:00
Zixuan Chen
5a233501cc perf: speed up import by reducing dag nodes 2023-07-18 01:23:49 +08:00
Zixuan Chen
d03617ca26 feat: add bench 2023-07-17 23:18:18 +08:00
Zixuan Chen
e993f1b155 feat: basic snapshot encoding 2023-07-17 12:27:11 +08:00
Zixuan Chen
6983a2b00c refactor: mov loro value to loro_common 2023-07-15 00:47:47 +08:00
Zixuan Chen
fc49b4b3b4 refactor: mov important basic types into loro-common 2023-07-14 16:38:53 +08:00
Zixuan Chen
dde0152912 refactor: prepare for snapshot encoding 2023-07-14 16:05:06 +08:00
Zixuan Chen
6311782943 perf: optimize compress & speed
but no cap for now
2023-07-13 22:43:02 +08:00
Zixuan Chen
346117ff54 feat: supports setting capacity 2023-07-13 16:57:41 +08:00
Zixuan Chen
f604a89fc3 refactor(bytes): refine interface 2023-07-13 15:33:49 +08:00
Zixuan Chen
8ebd41fa3d feat: connect diff calculator 2023-07-12 00:29:23 +08:00
Zixuan Chen
b1d438d08d fix: a weird deps bug
error[E0635]: unknown feature `proc_macro_span_shrink`
  --> /Users/zxch3n/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/lib.rs:92:30
   |
92 |     feature(proc_macro_span, proc_macro_span_shrink)
   |                              ^^^^^^^^^^^^^^^^^^^^^^
2023-07-10 15:57:55 +08:00
Zixuan Chen
2cbe21463c feat: list & text states 2023-07-04 11:27:09 +08:00