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 loro_internal::{EncodeMode, LoroCore, VersionVector};
|
||||
// use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use bench_utils::{get_automerge_actions, TextAction};
|
||||
use loro_internal::LoroDoc;
|
||||
|
||||
// #[allow(dead_code)]
|
||||
// fn parallel() {
|
||||
|
@ -62,5 +61,24 @@
|
|||
// }
|
||||
|
||||
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 rle::{rle_tree::UnsafeCursor, HasLength, Sliceable};
|
||||
use smallvec::SmallVec;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use debug_log::debug_dbg;
|
||||
use enum_dispatch::enum_dispatch;
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use loro_common::{HasIdSpan, PeerID, ID};
|
||||
|
@ -56,12 +57,14 @@ impl DiffCalculator {
|
|||
after: &crate::VersionVector,
|
||||
after_frontiers: Option<&Frontiers>,
|
||||
) -> Vec<InternalContainerDiff> {
|
||||
if self.has_all {
|
||||
let include_before = self.last_vv.includes_vv(before);
|
||||
let include_after = self.last_vv.includes_vv(after);
|
||||
if self.has_all && (!include_after || !include_before) {
|
||||
if !include_after || !include_before {
|
||||
self.has_all = false;
|
||||
self.last_vv = Default::default();
|
||||
}
|
||||
}
|
||||
|
||||
let affected_set = if !self.has_all {
|
||||
// if we don't have all the ops, we need to calculate the diff by tracing back
|
||||
|
|
|
@ -208,7 +208,7 @@ impl LoroDoc {
|
|||
let old_frontiers = oplog.frontiers().clone();
|
||||
oplog.decode(bytes)?;
|
||||
if !self.detached {
|
||||
let mut diff = self.diff_calculator.lock().unwrap();
|
||||
let mut diff = DiffCalculator::default();
|
||||
let diff = diff.calc_diff_internal(
|
||||
&oplog,
|
||||
&old_vv,
|
||||
|
|
Loading…
Reference in a new issue