From 14c4e9ccc6112077a51b4eacbcdca8f0702446e2 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 3 Sep 2024 19:14:58 -0700 Subject: [PATCH] bump derivre; add logging --- parser/Cargo.toml | 2 +- parser/src/earley/regexvec.rs | 8 +++++++- rust/Cargo.lock | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 709a2a6d..ac240cfd 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] toktrie = { git = "https://github.com/microsoft/toktrie", rev = "7cb20cd594428f5397f6159115d5e070e8c0935f" } -derivre = { git = "https://github.com/microsoft/derivre", rev = "9bf0f4842b012b963812a6099acf2cb86406adb2" } +derivre = { git = "https://github.com/microsoft/derivre", rev = "677799cfa3abb1a33928d40f81972b3a9c965e4f" } serde = { version = "1.0.192", features = ["derive"] } serde_json = "1.0.108" anyhow = "1.0.75" diff --git a/parser/src/earley/regexvec.rs b/parser/src/earley/regexvec.rs index 53f98990..4cebfe96 100644 --- a/parser/src/earley/regexvec.rs +++ b/parser/src/earley/regexvec.rs @@ -132,6 +132,8 @@ impl RegexVec { lexeme_idx: usize, mut budget: u64, ) -> Result { + let budget0 = budget; + let t0 = instant::Instant::now(); assert!(self.subsume_possible(state)); let small = self.rx_list[lexeme_idx]; self.set_fuel(u64::MAX); @@ -142,13 +144,17 @@ impl RegexVec { let c0 = self.exprs.cost(); let not_contained = self.relevance - .is_relevant_limited(&mut self.exprs, check, budget)?; + .is_non_empty_limited(&mut self.exprs, check, budget)?; if !not_contained { return Ok(true); } let cost = self.exprs.cost() - c0; budget = budget.saturating_sub(cost); } + let cost = budget0 - budget; + if false && cost > 10 { + println!("check_subsume: {}/{} {:?}", cost, budget0, t0.elapsed()); + } Ok(false) } diff --git a/rust/Cargo.lock b/rust/Cargo.lock index f1e00519..ebe3f049 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -65,7 +65,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "derivre" version = "0.1.0" -source = "git+https://github.com/microsoft/derivre?rev=9bf0f4842b012b963812a6099acf2cb86406adb2#9bf0f4842b012b963812a6099acf2cb86406adb2" +source = "git+https://github.com/microsoft/derivre?rev=677799cfa3abb1a33928d40f81972b3a9c965e4f#677799cfa3abb1a33928d40f81972b3a9c965e4f" dependencies = [ "ahash", "anyhow",