Skip to content

Commit 8c898ee

Browse files
authored
Perf: speedup snapshot import (#783)
* refactor: add custom parent resolver to arena * perf: don't need to scan values now * perf: now super fast decode * chore: add changeset * perf: skip an redundant checksum check * test: record a failed test case * fix: get depth err * refactor: hide kv from outside of inner_store * fix: id_to_idx misuse (not in arena doesn't mean not exist) * chore: fix a tiny detail * docs: add notes to id_to_idx method * docs: add invariants note to inner store * test: update local-events fuzz config
1 parent 9178d82 commit 8c898ee

18 files changed

Lines changed: 1046 additions & 155 deletions

File tree

.changeset/honest-brooms-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"loro-crdt": minor
3+
---
4+
5+
Perf: faster snapshot import speed

crates/examples/examples/draw.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ fn run_realtime_collab(peer_num: usize, action_num: usize, seed: u64) -> BenchRe
148148
doc.import(&updates).unwrap();
149149
let decode_update_duration = start.elapsed().as_secs_f64() * 1000.;
150150
let json_len = doc.get_deep_value().to_json().len();
151-
doc.log_estimate_size();
152151

153152
BenchResult {
154153
task: "realtime draw",

crates/fuzz/src/container/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub mod text;
66
pub mod tree;
77
pub use counter::*;
88
pub use list::*;
9-
use loro::{LoroError, LoroResult};
9+
use loro::{LoroError, LoroResult, LoroTreeError};
1010
pub use map::*;
1111
pub use movable_list::*;
1212
pub use text::*;
@@ -17,6 +17,7 @@ fn unwrap<T>(r: LoroResult<T>) -> Option<T> {
1717
match r {
1818
Ok(v) => Some(v),
1919
Err(LoroError::ContainerDeleted { .. }) => None,
20+
Err(LoroError::TreeError(LoroTreeError::TreeNodeDeletedOrNotExist(..))) => None,
2021
Err(e) => panic!("Error: {}", e),
2122
}
2223
}

crates/fuzz/tests/small_fuzz.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use arbtest::arbitrary::{self, Unstructured};
2-
use fuzz::crdt_fuzzer::{test_multi_sites, Action, FuzzTarget};
2+
use fuzz::{
3+
actions::GenericAction,
4+
crdt_fuzzer::{test_multi_sites, Action, FuzzTarget},
5+
};
6+
use Action::*;
37

48
fn prop(u: &mut Unstructured<'_>, site_num: u8) -> arbitrary::Result<()> {
59
let xs = u.arbitrary::<Vec<Action>>()?;
@@ -43,3 +47,29 @@ fn random_fuzz_1s_5sites_1() {
4347
fn random_fuzz_1s_5sites_2() {
4448
arbtest::builder().budget_ms(1000).run(|u| prop(u, 5));
4549
}
50+
51+
#[ctor::ctor]
52+
fn init() {
53+
dev_utils::setup_test_log();
54+
}
55+
56+
#[test]
57+
fn a_failed_case() {
58+
test_multi_sites(
59+
5,
60+
vec![FuzzTarget::All],
61+
&mut [Handle {
62+
site: 220,
63+
target: 142,
64+
container: 63,
65+
action: fuzz::actions::ActionWrapper::Generic(GenericAction {
66+
value: fuzz::actions::FuzzValue::I32(-475812747),
67+
bool: true,
68+
key: 3772263912,
69+
pos: 5074681398301933407,
70+
length: 14215598495239327317,
71+
prop: 11034577274858974974,
72+
}),
73+
}],
74+
);
75+
}

0 commit comments

Comments
 (0)