mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 12:25:03 +00:00
perf: fix a perf regression
This commit is contained in:
parent
addadcdce5
commit
299f00d90f
4 changed files with 32 additions and 10 deletions
|
@ -1,6 +1,5 @@
|
||||||
// use bench_utils::{get_automerge_actions, TextAction};
|
use bench_utils::{get_automerge_actions, TextAction};
|
||||||
// use loro_internal::{EncodeMode, LoroCore, VersionVector};
|
use loro_internal::LoroDoc;
|
||||||
// use rand::{rngs::StdRng, Rng, SeedableRng};
|
|
||||||
|
|
||||||
// #[allow(dead_code)]
|
// #[allow(dead_code)]
|
||||||
// fn parallel() {
|
// fn parallel() {
|
||||||
|
@ -62,5 +61,24 @@
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// real_time()
|
let actions = get_automerge_actions();
|
||||||
|
let loro = LoroDoc::default();
|
||||||
|
let loro_b = LoroDoc::default();
|
||||||
|
let text = loro.get_text("text");
|
||||||
|
let mut count = 0;
|
||||||
|
for TextAction { pos, ins, del } in actions.iter() {
|
||||||
|
{
|
||||||
|
let mut txn = loro.txn().unwrap();
|
||||||
|
text.delete(&mut txn, *pos, *del).unwrap();
|
||||||
|
text.insert(&mut txn, *pos, ins).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
loro_b
|
||||||
|
.import(&loro.export_from(&loro_b.oplog_vv()))
|
||||||
|
.unwrap();
|
||||||
|
count += 1;
|
||||||
|
if count % 1000 == 0 {
|
||||||
|
println!("{}", count);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use debug_log::debug_dbg;
|
||||||
use loro_common::IdSpanVector;
|
use loro_common::IdSpanVector;
|
||||||
use rle::{rle_tree::UnsafeCursor, HasLength, Sliceable};
|
use rle::{rle_tree::UnsafeCursor, HasLength, Sliceable};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use debug_log::debug_dbg;
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
use fxhash::{FxHashMap, FxHashSet};
|
||||||
use loro_common::{HasIdSpan, PeerID, ID};
|
use loro_common::{HasIdSpan, PeerID, ID};
|
||||||
|
@ -56,11 +57,13 @@ impl DiffCalculator {
|
||||||
after: &crate::VersionVector,
|
after: &crate::VersionVector,
|
||||||
after_frontiers: Option<&Frontiers>,
|
after_frontiers: Option<&Frontiers>,
|
||||||
) -> Vec<InternalContainerDiff> {
|
) -> Vec<InternalContainerDiff> {
|
||||||
let include_before = self.last_vv.includes_vv(before);
|
if self.has_all {
|
||||||
let include_after = self.last_vv.includes_vv(after);
|
let include_before = self.last_vv.includes_vv(before);
|
||||||
if self.has_all && (!include_after || !include_before) {
|
let include_after = self.last_vv.includes_vv(after);
|
||||||
self.has_all = false;
|
if !include_after || !include_before {
|
||||||
self.last_vv = Default::default();
|
self.has_all = false;
|
||||||
|
self.last_vv = Default::default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let affected_set = if !self.has_all {
|
let affected_set = if !self.has_all {
|
||||||
|
|
|
@ -208,7 +208,7 @@ impl LoroDoc {
|
||||||
let old_frontiers = oplog.frontiers().clone();
|
let old_frontiers = oplog.frontiers().clone();
|
||||||
oplog.decode(bytes)?;
|
oplog.decode(bytes)?;
|
||||||
if !self.detached {
|
if !self.detached {
|
||||||
let mut diff = self.diff_calculator.lock().unwrap();
|
let mut diff = DiffCalculator::default();
|
||||||
let diff = diff.calc_diff_internal(
|
let diff = diff.calc_diff_internal(
|
||||||
&oplog,
|
&oplog,
|
||||||
&old_vv,
|
&old_vv,
|
||||||
|
|
Loading…
Reference in a new issue