Fix bug in scanner cache PR when running kprove#2408
Conversation
…ern` (#2390) * fix bug where command line invocation was not printed with -v * delete dead code * code to serialize scanner * implement Comparable on TerminalLike * make tokens deterministic in numbering * implement code to deserialize scanner * add tests for bug * fix #2372 - false negative of invalid precedence error * fix bug involving syntax added by compiler to main module * fix precedence conflict in test * Fix indent Co-authored-by: rv-jenkins <admin@runtimeverification.com>
|
@dwightguth can you remind me how is this supposed to work? |
|
The goal of this PR isn't to stop scanners from being created when you run kompile; that's because we don't have any logic for deciding if the cached scanner is out of date, nor would it be particularly easy to do this. It is merely to allow us to reuse scanners during krun and eventually kprovex that are identical to the one generated by kompile |
|
Ok, fine for now. |
|
Sure, in theory you can, but any substantive change to the definition's syntax will ultimately invalidate the scanner, whereas you have now introduced a new check for equality that is pretty massive that has to be run on every invocation of kompile. I'm not convinced it's really going to help much during day to day development. Besides, my primary goal with this change is to reduce time spent on the hot path, which doesn't include time spent in kompile. We can separately try to improve time spent in kompile, of course, but generating the scanner isn't generally where most of that time is being spent in large definitions right now. Regardless, I'm going to merge this and we can continue to iterate improvements |
|
We do grammar comparison when we invalidate cached rules anyway. |
|
We do grammar comparison when we invalidate cached rules if we have rules in the module in question. However, if the definition consists of many modules each with a few pieces of syntax, all imported into one module with no rules, then we won't actually need to do the cache invalidation check on the entire grammar all at once. Thus, you would still end up doing additional work. |
You should not need to review the first commit as it is identical to the one previously reviewed. This PR just fixes the issue where we were still trying to serialize the scanner when parsing rules in kprove.
Note that we do not need to fix the case where we are deserializing the scanner yet, because we do not yet use the serialized scanner while parsing anything other than search patterns. In a follow-up PR, once this is suitably working, we will need to ensure that we use the cached scanner during kprovex