Skip to content

Commit

Permalink
dfa: fix approximate cache size
Browse files Browse the repository at this point in the history
Unbelievably, this was using the size of the compiled prog *and* the
heap memory used by the cache to compute the total memory used by the
cache. The effect of this is that the reported size might be much bigger
than what is actually used by the cache. This in turn would result in
the lazy DFA thrashing the cache and going quite slow.
  • Loading branch information
BurntSushi committed Feb 28, 2023
1 parent 39186c1 commit 6c64620
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ impl<'a> Fsm<'a> {
/// inputs, a new state could be created for every byte of input. (This is
/// bad for memory use, so we bound it with a cache.)
fn approximate_size(&self) -> usize {
self.cache.size + self.prog.approximate_size()
self.cache.size
}
}

Expand Down

0 comments on commit 6c64620

Please sign in to comment.