Commit Graph

594 Commits

Author SHA1 Message Date
Fedor Isakov dcfe56c004 Deprecate RulesList, prepare to drop the class. 2020-12-03 20:17:47 +01:00
Fedor Isakov f6123273d4 Minor refactoring: drop usages of Program.rulesLists() method. 2020-12-01 21:55:17 +01:00
Fedor Isakov ac6972106b Fix memleak in LogicalState. Ensure processing machinery gets properly shut down on session end.
Clearing the controller field in LogicalState is not enough,
apparently some instances are leaked before the session
gets terminated.
2020-11-27 11:13:38 +01:00
Fedor Isakov b51d8257ba Ensure runtime exceptions are caught when evaluating predicates.
An exception raised by a predicate solver must not break evaluation.
2020-11-24 13:41:24 +01:00
Grigorii Kirgizov 8ac38578ef minor: add docs to incremental stages 2020-11-18 11:36:28 +03:00
Grigorii Kirgizov 15d6fe8eae Introduce ProcessingSession for creating session from token & ending it
Introduced to discern incremental strategies: Full,Preamble,Default.
because how SessionToken is used and stored depends on it.
EvaluationSessionImpl now simply dispatches to it.
Also rename 'IncrementalProcessing' to 'ProcessingStrategy'.
2020-11-18 11:36:28 +03:00
Fedor Isakov a403b1a252 Update Idea project in reactor. 2020-10-23 12:26:30 +02:00
dependabot[bot] 7971353f31
Bump junit from 4.12 to 4.13.1 in /reactor/Test
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-13 07:03:23 +00:00
Grigorii Kirgizov 0df40a65f1 Refactor incremental logic in ConstraintsProcessing into separate facade (MPSCR-71)
Relations between stages and entry points into incremental
algorithm are now much clearer.
2020-09-01 17:01:06 +03:00
Grigorii Kirgizov da27c7ccd4 Fix some tests given changes in Journal
Also enable old incr tests that failed b/of missing features.
Remove old flaky disabled test.
2020-09-01 17:01:06 +03:00
Grigorii Kirgizov 5790a83471 Refactor MatchJournal traverse & modification logic (MPSCR-71)
Now journal's internal class Cursor is responsible for it.
2020-09-01 17:01:06 +03:00
Grigorii Kirgizov 1bcf80a9b2 Introduce IncrementalStage-s (MPSCR-71)
Incremental algorithm is stricter now in relation to
how it reads MatchJournal and operates on it.
Previously each incremental stage required full traversal.
Now all stages run on each chunk in a single traversal.

Separate journal traversal from incremental logic required for each Chunk.
2020-09-01 17:01:06 +03:00
Grigorii Kirgizov 19fa16c731 minor: disable excessive traverse in Journal made for MPSCR-65. breaks 2 tests 2020-09-01 16:20:08 +03:00
Grigorii Kirgizov 96f0a2e037 Provide correct journal position for re-exec in continueReplacedHeads (fixes MPSCR-68)
Also completes MPSCR-65. Another test for it now passes.
2020-09-01 13:37:45 +03:00
Fedor Isakov 38e34b4431 Reinforce RuleIndex.update() to be independent of RuleDiff.
RuleDiff may not be in sync with RuleIndex's state.
2020-08-20 14:20:52 +02:00
Fedor Isakov 4e89325d47 Reactor: enable to reuse RuleIndex from token in non-incremental mode. 2020-08-20 14:20:51 +02:00
Fedor Isakov 7666c64507 Make use of RuleIndex update in incremental mode. 2020-08-06 17:45:47 +02:00
Fedor Isakov d619fdf31b Ignore a test that isn't working as it's supposed to.
The test substructuralTS_indirectResourceDependency is not doing what it's intended
to be doing b/c of apparenly wrongly understood contract of the `also()` method.
It is not supposed to pass the result of the computation to the "chained" method.

Compare `T.also(block: (T) -> Unit): T` and `T.let(block: (T) -> R): R`.

After having fixed the code, the test no longer passes.
2020-08-06 17:45:47 +02:00
Fedor Isakov eec84330fc Make RuleIndex incrementally updatable. Drop segments feature. 2020-08-06 17:45:47 +02:00
Fedor Isakov a003211a2c Minor optimization of term trie. 2020-08-06 17:45:47 +02:00
Fedor Isakov c282911a3c Provide support for tracking usages number of MutableLogical. 2020-07-30 17:14:40 +02:00
Grigorii Kirgizov 43e39ca4a1 Clear LogicalState for occurrences dropped during incremental invalidation 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 2a0d4ef076 Observe all unbound logicals inside Occurrence to check contract (MPSCR-66)
Previously only logicals directly used ar occurrence args
were observed. Now terms in occurrence args are traversed
recursively and all contained logicals are observed.

Also clear occurrence contract observers on discarding occ-s.
Introduce a generic way to clear observers in LogicalState.
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 3ef1c53a85 Move TermWalker from tests package to core.internal to reuse for MPSCR-66
Also convert it to Kotlin
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 54335cb2fd Introduce incrementality-allowed levels: No, Unsafe, Yes
Instead of simple allowed/not option sometimes Unsafe
is useful. 'Unsafe' status may be present when there're
few "bad" rules.
With this level end code may resolve to go with
incrementality without strict guarantees.
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 0d0813d352 Add logical incr contract assertions as observers (implements MPSCR-66) 2020-07-22 15:51:56 +03:00
Grigorii Kirgizov f2d1f089ad Use rule match identity as feedback key for TypesIndex instead of rule unique tag
It seems to reflect the exact information needed: there's
one-to-one correspondence between feedback and its match.
While using rule unique tag as feedback key in TypesIndex
relied on several assumptions.
Also there's less use of MatchJournal information with this.
Previously parent principal match was passed to FeedbackConsumer.
2020-07-22 15:27:46 +03:00
Grigorii Kirgizov 53a5d2f489 Disable one test for substructural TS (most general case of MPSCR-65) 2020-07-22 15:27:46 +03:00
Grigorii Kirgizov d9b984aee9 minor: modify expectType test according to fix of MPSCR-64
Fix expands notion of principal rules so that failed rules
are now principal. It's reflected in this change to test.
2020-07-22 15:27:46 +03:00
Grigorii Kirgizov 3093b4678c Implement incremental handling of discarded principal occurrences (MPSCR-65)
Matches which discard principal occurrences must be handled specially
on incremental execution. Imagine such match inserted in journal
before other matches with the same occurrence in head.
Because inserted match discards the occurrence, following matches
can't match on it. They must be invalidated. (Relevant for MPSCR-62)
See tests for substructuralTS.

Commit refactors machinery of `dropDiscardingMatchesFor` in
ConstraintsProcessing that was incomplete, as revealed by MPSCR-64.

Relaxes small memory opt introduced in commit a2675351:
Now justifications in Occurrences are not shared with their
activating matches. See JustifiedOccurrenceCreator.
Introduced machinery requires that Occurrences had their own
Evidence (because `dropDiscarding` invalidates by Occurrences).
Previously algorithm was invalidating Chunks only by Evidence
from rule matches, that's why only RuleMatches had to have
unique Evidence, while Occurrences could bear less info.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 8cb6aa72d3 minor refactorings in engine (some moves & renames) 2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 3bdc1123ad Incr engine: refine reexecution position for reactivated occurrences
In short, this change restricts information algo needs from journal.
It restricts how far invalidation stage goes into journal.
Previously it fed ExecQueue with position arbitrarily far in 'past',
whereas now it feeds the closest valid position (the 'present').
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 76b37c3f3e minor refactorings in engine
Refine interface of RuleMatchEx to use Occurrence,
move one of its function as ext fun (as in TODO).
Fix duplication of extension functions for IncrSpec.
Ensure some contracts in ExecutionQueue.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov ef7f66dd3e Minor fix: always reset journal in incremental session.
Without it in certain cases ConcurrentModificationException
(on internal journal linked list) could arise.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov f402ce33c8 Don't clear Dispatcher state for discarded match heads: it's unnecessary 2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 53d0bd2060 Add tests for substructural typesystems (MPSCR-65) & reproduce MPSCR-64
These typesystems will probably extensively use discarded constraints.
So need more tests for these cases.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 5ebac30e07 minor: remove unused functionality in ExecQueue according to 'fixme' 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 693cfbb15d Fix incorrect Dispatcher state clear on incremental invalidation
Some constraints could be missed: those which
are activated and discarded in the same Chunk.

Dispatcher weren't cleared from them
and stale matches could remain in its state.
Through these matches their invalidated heads
could get into incremental execution queue
which led to assert violation in MatchJournalImpl.reset
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 8629e5abfc Properly handle non-principal rules with origins in incremental algo
Fixes IncrClassHierarchy.modifyClsHierarchyTypeParams test.

Key point is that changes to rules causing their
regeneration must be reflected in program.
There appeared to be cases when it's not true.
It's a case of non-principal rules with origins.
Such rules are called "weak principal" rules.

Matches of weak principal rules are not recorded
in Journal (as is for principal rules), but instead
they become part of their parent MatchChunk.
(In essense, tags of weak principal rules are
recorded in parent chunk).
With this, when a weak principal rule changes,
matches of all principal rules whose computation
depends on them are correctly invalidated.
(Example rules: findHierarchy_Classifier)

Relevant for MPSCR-62.
2020-07-01 14:36:48 +03:00
Fedor Isakov 8b71274a57 Update Kotlin to 1.3.70 for Reactor lib. 2020-06-25 14:30:31 +02:00
Grigorii Kirgizov af3170e428 Remove invalid assert from incremental processing
Some time ago "mixed" matches (with both principal and non-principal heads)
were allowed and are handled by Journal. So now principal constraints
can lead to non-principal matches, which renders assert invalid.
(Relevant for MPSCR-62)
2020-06-08 19:02:20 +03:00
Fedor Isakov 7f37a15f4e IDEA project files update after switch to 2020.1 2020-06-04 12:40:34 +02:00
Fedor Isakov c24f4f75a4 Optimize and refactor TermGraphUnifier. Beautify the code.
Avoid internalizing a (sub-)term that has not been unified with
 a variable, thus saving on unnecessary accounting.
2020-06-04 11:44:07 +02:00
Fedor Isakov 202b83b984 Fix typo in Profiler -- enable to trace parent site frequencies. 2020-06-04 11:44:07 +02:00
Fedor Isakov 18933cfcf2 Support trivial bindings in unification results. Minor refactoring.
Trivial substitutions such as [X->X] are optionally available.
May prove usable when discovering variables within a term.
2020-06-04 11:44:07 +02:00
Fedor Isakov c5d9e798a3 Introduce DataProvider. Allow predicates to access Supervisor.
DataProvider is an abstract way to associate any data with the
runtime object, such as Supervisor.
Predicate solvers that ought to be stateful may make use of
DataProvider to access the internal state.
2020-06-04 11:44:06 +02:00
Grigorii Kirgizov e1ff37b815 Document RuleMatchingProbe (most importantly, its matches() contract). 2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 8447081b26 Return from Probe only matches relevant to last expanded Occurrence. Fixes MPSCR-59 2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 4928daf3fc Add tests related to program execution pattern exhibited by MPSCR-59 2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 49d8507eed Avoid duplicate subscription of Occurrences on LogicalState
Previously it was done twice: at Occurence creation
and in ConstraintsProcessing.processActivated.
Occurrences now constructed in 'dead' state (without observers).
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 17de7bf9fe Fix tracking of logical observers: avoid duplicates & clear observers correctly
Commit also aligns Observable/Observer interfaces a bit.

Side note: the current role of LogicalState is to only
forward events from Logical to Observers with augmented
information (i.e. providing Controller to handle event).
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 3f2b7df7b4 Add sanity check that every match has active occurrence in its head (MPSCR-59) 2020-04-30 15:38:33 +03:00
Grigorii Kirgizov 14e4385382 Fix incorrect reset of occurrences that led to invalid occurrences state
Resulted in some in fact dead occurrences being reactivated
2020-04-30 15:38:33 +03:00
Grigorii Kirgizov 5c86ff2d4d Rename notion of 'reactivate' in incremental sense to 'activateContinue' to avoid ambiguity 2020-04-19 13:43:05 +03:00
Grigorii Kirgizov c6dca919ca Fix loss of some rule matcher probes with state crucial for incremental sessions 2020-04-19 13:43:05 +03:00
Fedor Isakov 9cacd25e53 Drop unused class from reactor API. 2020-04-13 17:58:33 +02:00
Grigorii Kirgizov 13e1e10f59 Disable assertion failing for lambdacalc, related to proper parent match tracking
Problem lies in that journal doesn't track all justifications
for reactivated occurrences. For a parent of such occurrence
its original activating match is considered, while
justifications from the Reactivating match aren't tracked.
So, this information about immediate reactivating parent is lost.

lambdacalc lang typesystem heavily uses reactivation, so it fails.
2020-03-26 13:40:42 +03:00
Grigorii Kirgizov 654031c05c Extend docs for Justified.justifiedBy relation, add assertion for its antisymmetric property 2020-03-26 13:40:42 +03:00
Grigorii Kirgizov a2675351b5 Track justifications for all occurrences, but weaken information they carry.
Now Evidence isn't unique for each Chunk: Occurrence Chunks fully
share evidence and justifications with their activating match.
So, less collections of justifications are created, approx. 2 times less.
2020-03-26 13:40:41 +03:00
Grigorii Kirgizov 6a53d15a21 Refactor: move logic related to tracking parent match from ControllerImpl to MatchJournal
Relates to machinery introduced in MPSCR-47.
Previously parent match was maintained in Controller on Java call stack.
Now this stack of parent matches is maintained manually in MatchJournal.

So MatchJournal gains new invariant: parentChunk()
returns correct parent after each logMatch() call.
Several tests fail, also need to maintain this
invariant after logActivation() calls.
2020-03-26 13:40:41 +03:00
Grigorii Kirgizov b10b69545e Refactor: hide mutability of Chunk.entries (both as var and as MutableList). Add a bit of docs. 2020-03-12 18:02:22 +03:00
Grigorii Kirgizov af0a118273 Fix mistake introduced in 591865b9: return copy of invalidated tags, not ref (fixes MPSCR-50) 2020-03-12 11:02:46 +03:00
Fedor Isakov 856c7cc777 Dereference all refs within term on unification.
Method findSolution now walks all refs inside a term.
This guarantees no "hidden" cycles, but also breaks the
"cyclic term" feature.
2020-03-11 12:29:04 +03:00
Fedor Isakov 914507329e Introduce checking flag to context, avoid failure in rule match.
Processing a match may fail because of unification went wrong.
To avoid these transient failures to propagate to program trace,
context can optionally abort instead of fail, which is then
recovered from.
2020-03-11 12:28:23 +03:00
Grigorii Kirgizov 591865b9cb Small opt: skip traversing journal when there're no rules to invalidate/add 2020-03-10 13:31:34 +03:00
Grigorii Kirgizov 60f838eb28 Add tests for unification of terms with var refs 2020-03-10 12:22:22 +03:00
Grigorii Kirgizov 441f203084 Revert "Remove throwing NPE on Term.symbol() given updated NotNull contract"
Leave exception because can't strongly rely on NotNull java annotation.
This reverts commit 6f49d63f
2020-03-06 14:04:18 +03:00
Grigorii Kirgizov 54f8c7a6be Change usages of ConstraintsProcessing.parentChunk() to usages of tracker parent 2020-03-06 14:04:18 +03:00
Grigorii Kirgizov 6f49d63fae Remove throwing NPE on Term.symbol() given updated NotNull contract 2020-03-02 22:08:51 +03:00
Grigorii Kirgizov 2ec4abe860 Maintain invariant that justifications of a MatchJournal.Chunk are inherited by all its children Chunks
Retroactive addition of justifications to a parent Chunk (MatchChunk.justifyBy),
introduced by a recent fix for MPSCR-47, can broke this invariant.
2020-03-02 22:08:51 +03:00
Grigorii Kirgizov 81721a0067 Ensure MatchJournalImpl.replay is idempotent operation, add test for it
Add another test for replaying inside Chunk.
Doesn't pass for now for the lack of machinery for tracking precise Pos.
2020-03-02 22:03:05 +03:00
Grigorii Kirgizov 5c4b1f8263 Add test that ensures that justifications invariant is preserved by a fix to MPSCR-47
Invariant ensures that retroactively added justifications
(added on past parent chunk, see fix commit) are propagated
for all relevant children of justified parent chunk.
2020-03-02 22:03:05 +03:00
Grigorii Kirgizov 2b92e5df04 minor: rename test method princConstraint to pconstraint 2020-03-02 17:58:05 +03:00
Grigorii Kirgizov 7af3f29a6d Provide additional justifications for nearest relevant Chunks on certain matches. Fixes MPSCR-47
Such cases arise when non-principal rules can match on principal occurrences
(for example, capture_Classifier rule in BaseLanguage typesystem).
We don't want to lost justifications provided by these occurrences,
so store them in the nearest relevant chunk --- which is a parent match chunk.

With this the invalidation of the tracked principal occurrences will lead to invalidation
of this relevant match and so to invalidation of any effects produced by non-principal rules,
because they're logged exactly under the chunk of that relevant match.
See tests from previous commits for example.
2020-03-02 17:11:26 +03:00
Grigorii Kirgizov ccd3ed6d45 Add tracking of last justifying MatchChunk during program eval to avoid searching for it in Journal
Such machinery is needed inside ControllerImpl.processBody
to provide nearest relevant match to feedback handling.
Also required for a fix for MPSCR-47.
Also enables back one assertion in incremental processing on rm stage.
2020-03-02 17:11:26 +03:00
Grigorii Kirgizov a9af387816 Fix IndexedSignatureSet.remove method which didn't clear signatures, clear internal index also 2020-03-02 17:11:26 +03:00
Grigorii Kirgizov 38924ef64d Add 2 tests on incremental engine, reproduces case of MPSCR-47 2020-03-02 17:11:26 +03:00
Grigorii Kirgizov 8102080809 Refactor: drop unused on MPS level java interfaces 2020-03-01 17:12:15 +03:00
Grigorii Kirgizov 37dd3ee4a8 Refactoring: extract Justified interface and hide lower-level work with Int sets behind it
Make Occurrence a Justified entity and drop .justifications() from
ConstraintOccurrence.java because justifications are used only internally.
A single justification is now called Evidence (typealias to Int),
so Justified entities are justified by Evidence-s.
2020-03-01 17:12:15 +03:00
Fedor Isakov 3193a9c078 Adjust nullability contract in occurrence matcher.
Term's symbol can't be null.
Also guarantee that when processing a match no null
values occur.
2020-02-28 17:42:54 +01:00
Grigorii Kirgizov f9602c8bbf Throw on null terms in term trie (relates to MPSCR-40)
For more clear errors stemming from usage of constraints with null values, which ain't handled
2020-02-12 20:15:07 +03:00
Grigorii Kirgizov a1682106d8 Let Dispatcher handle future matches and don't store postponed matches (fixes MPSCR-37) 2020-02-05 18:52:18 +03:00
Grigorii Kirgizov f61c436809 Add tests to verify expected behavior of repeated expansion of the same occurrence (MPSCR-37)
Tests are structured similar to how occurrences are processes with ExecQueue
and its 'postponedFutureMatches' in incremental processing in ConstraintProcessing.
Also don't ignore one old test.
2020-02-05 18:52:18 +03:00
Grigorii Kirgizov 238b9e10cf Fix Rete RuleMatcher .forget method 2020-02-05 18:52:18 +03:00
Grigorii Kirgizov 438d8e6e9a Ensure rule tags of all dropped rule matches are propagated as algo output (MPSCR-32) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 51ec8973d2 Add test to reproduce MPSCR-35 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov efd22872a9 Handle case of invalidating stale discarding matches (MPSCR-35) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 18fc4592f0 Modify logging methods of MatchJournal to return logged Chunks 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 7074112b7c Revert "Refine logic for finding activation Pos to correctly handle discarding rules"
This reverts commit 746c4808
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 3b0008ad22 Remove some unused code 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 840d02c9f7 Provide restricted version of MatchJournal.replay to utilize the descendants information of chunks
In some cases replay could 'overshoot' because the position replayed to was invalidated.
The natural way is to replay to the last descendant of such activated occurrence
and continue execution from here.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov ab3eb716ae Refactor ExecPos from ExecQueue to work with OccChunk instead of any Occurrence
This interface change it means that only Occurrences from previous session can be reexecuted.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov b909706a04 Refine logic for finding activation Pos to correctly handle discarding rules 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov d7c2b7f977 Extend MatchJournal with replayUntil method 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov b2cf46f813 Refactor a bit of logic responsible for finding appropriate place for inserting descendant chunk 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov d69b7bff98 Fix incremental match insertion logic for corner case of rules of equal priority
Behavior was incorrect in the case of discarding rules.
Several discarding matches could appear on the same occurrence,
beacuase newer incremental matches were inserted before later one,
thus seeing their occurrence as still active and stored.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov a4b28509a8 Provide additional information about parent principal chunk to Feedback (MPSCR-32)
Allows to track connection between invalidated matches and reported feedback.
In future this Journal info can help in simplifying error reporting.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov e55e67bc08 Modify EvaluationResult to also return the set of tags of all invalidated rules (MPSCR-32) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 79c31a44ba Handle journal reset for occurrences: upd their status (eg !alive). Add test for one error caused by it.
Occurrences which weren't yet activated (according to current journal position) can't be reactivated.
Test program is an example of such case.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov ba8d00c224 Handle incr exec of cases unhandled with introduced mem opt. Added test passes. 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 9aaf35561a Mem opt: store RuleMatchers only for principal rules between sessions. Add a test for incr processing.
The number of preserved matchers is around 4-10 times less.
The added test is an example of programs handled incorrectly with this opt. Fails now.
2020-02-05 12:29:33 +03:00
Fedor Isakov e763b0a3eb Fix maven source plugin's version 2020-01-20 19:43:56 +01:00
Fedor Isakov 8af582f9b2 Refactoring: simplify contract b/w controller and logical state. 2020-01-14 15:34:54 +01:00
Fedor Isakov d208e802b9 Remove unnecessary feature: StateFrameStack is no longer used.
StateFrameStack adds no functionality but requires too much processing.
Rename StateFrameStack -> LogicalState.
Rename ProcessingStateImpl -> ConstraintsProcessing.
Simplify occurrence's logical observer.
Introduce transient dependency on controller to LogicalState.
Keep logical state as part of session token, avoid re-initializing
all logical observers.
Make replaying of match journal independent of controller.
2020-01-10 13:51:07 +01:00
Fedor Isakov 01195cb1ac Drop unused methods from Rule interface. To be reinstated in RuleEx. 2020-01-02 17:20:13 +01:00
Grigorii Kirgizov ecc948c1fc Add, remove and merge observers on Logical always on their roots. Fixes MPSCR-28 2019-12-23 21:13:07 +03:00
Grigorii Kirgizov 1f69ff7d57 Reproduce MPSCR-28 with a test in Reactor 2019-12-23 18:14:41 +03:00
Fedor Isakov 271df160bb Optimize rete rule matcher for dropping occurrences.
Introduce a reactive scheme: alpha node has "dependent" nodes which
it can invalidate transitively. Drop block initiates invalidation,
intro block actually drops the nodes.
2019-12-08 17:48:01 +01:00
Fedor Isakov 2199905ea2 Enhance profiler to report actual time spent at probe locations.
Instead of just reporting the times each probe has been called,
collect and calculate the actual time taken by each probe location from
the whole backtrace pool.
2019-12-08 16:28:31 +01:00
Fedor Isakov 4eb93f20f9 Re-organize places in reactor to gather profiling information. 2019-12-08 15:44:36 +01:00
Fedor Isakov 5d63ec31e1 Remember probes for activated occurrences, optimize drop time.
Avoid searching for matching rules again when discarding occurrence.
2019-12-08 15:37:56 +01:00
Fedor Isakov 818d1a4dbc Fix linked list implementation. Fixes MPSCR-18
New implementation enables the previously failing tests to pass.
2019-11-26 23:07:42 +01:00
Fedor Isakov 65daa76c6b Remove droppedTrail. Optimize operation with consumed signatures. Restore test.
It appears the feature that tracks the occurrences that have been
dropped
requires too much memory.
2019-11-26 11:26:42 +01:00
Fedor Isakov 9fab2e9d34 Refactor and redesign ReteRuleMatcher for better memory footprint.
Drop layer prototype, make layer mutable.
Keep nodes in a layer in a linked list with fail-safe iterator.
Introduce update queue for update blocks.
Update blocks run incrementally unless reset.
Maintain trail of introduced and dropped occurrences.
Generation iterates over nodes in the last (final) layer incrementally,
unless reset.
Introduce new test.
2019-11-24 13:34:59 +01:00
Fedor Isakov 65f7b493be Revert "Add ReactivateBlock in Rete Matcher to correctly handle reactivation. Fixes MPSCR-17"
This reverts commit f96155496f.
I need to revert this commit to avoid merging problems. Going to reapply
it later if necessary.
2019-11-24 13:34:07 +01:00
Grigorii Kirgizov f96155496f Add ReactivateBlock in Rete Matcher to correctly handle reactivation. Fixes MPSCR-17 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov 32a1ef77c9 Add test (fails now) for a new bug MPSCR-17 in Rete Matcher concerned with reactivation 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov e7b374ce50 Fix calls to trace.reactivate (there were extra calls in some exec paths) 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov 716e285c0c Small cleanup of EvaluationTrace usage 2019-11-07 17:14:40 +03:00
Grigorii Kirgizov f80371e148 MPSCR-14: Correctly trace incrementally reactivated occurrences. Fixes the bug. 2019-11-07 15:43:02 +03:00
Grigorii Kirgizov 45df4d845f Minor cleanup: remove DependentRulesSpec and its usages in RulesDiff
for historical documentation purposes, why it was needed:
It was used for specifying and handling rules which must be simply removed
without all related incremental invalidation machinery.
Long time ago some of these dependencies weren't captured
and such "simply dependent" rules must have been handled separately.
Currently it's handled by general invalidation case.
2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 572a2cbfd5 Revert "Revert "MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case.""
This reverts commit a0b2af95
This together with preceding changes concerned with preserving Rules finally fixes MPSCR-4.
2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 95214fcae9 Rename 'handlers' in Program to 'rulesLists' 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 87e9251242 Add RulesDiff.getPreserved() accessor to preserved rules 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov f343ba0d3b Adjust to changes in SessionToken & RulesDiff interfaces 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov bfcee33ec9 Modify SessionToken to preserve old rules instead of tags & RulesDiff to also distinguish preserved rules 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 3caeddcb63 Upd docs for StateFrame & add docs for StateFrameStack 2019-11-06 12:43:03 +03:00
Grigorii Kirgizov 510c3cd479 MPSCR-5: Clear all logicals from current StateFrameStack observer on incremental session teardown. 2019-11-06 12:16:11 +03:00
Fedor Isakov a0b2af95c9 Revert "MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case."
This reverts commit 0dd7f8c70f.
2019-11-04 15:58:54 +01:00
Grigorii Kirgizov 0dd7f8c70f MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case.
Slightly extend RuleMatcher interface.
Store RuleMatcher instances instead of RuleMatcherProbe in SessionToken.
2019-10-31 22:20:19 +03:00
Grigorii Kirgizov a095b2e222 Provide better (hopefully) name & explanation, undeprecate and provide missing impl for 'forgetSeen' method 2019-10-15 21:17:24 +03:00
Fedor Isakov 17f5bd64b0 Optimize Dispatcher: ensure allMatches are calculated lazily on request. 2019-10-08 13:20:40 +02:00
Fedor Isakov 445108da74 Fix RuleIndex returning too many matches for a constraint w/wildcard arg. 2019-10-08 13:16:56 +02:00
Fedor Isakov b283f657cf Fix a nasty bug in logical context.
A meta logical within a pattern was not properly initialized before the rule body is processed.
2019-10-02 13:54:11 +02:00
Fedor Isakov e69909f3be Some more optimizations in Rete rule matcher. 2019-10-01 16:25:12 +02:00
Fedor Isakov 31c95cd069 Bump up reactor version to 0.9.14. 2019-09-30 16:31:59 +02:00
Fedor Isakov c7b07f3b1a Adapt to the new persistent collections API. 2019-09-30 16:31:59 +02:00
Fedor Isakov 8ce96ec41e Introduce an abstraction layer of type aliases for persistent collections. 2019-09-30 16:31:59 +02:00
Fedor Isakov 04164e1039 Add some more profiling blocks. 2019-09-30 16:31:59 +02:00
Fedor Isakov 38e71db7e8 Revive and refactor ReteNetwork-based rule matching algorithm.
ReteNetwork is faster on large samples.
RuleMatchingProbe is mutable and not persistent, no need to update value.
2019-09-30 16:31:59 +02:00
Fedor Isakov f9b38113f5 Refactor and cleanup Dispatcher for better readability. Drop hacky stuff. 2019-09-30 16:31:59 +02:00
Fedor Isakov 60c39f2811 Add a test for a peculiar use case. Only triggered in production. 2019-09-30 16:31:59 +02:00
Fedor Isakov f21c01246f Introduce feature: optimize rule index for arguments matching.
RuleIndex indexes rules by constraint arguments value.
The additional feature allows to keep indexed also the head position
of the matched constraint.
2019-09-30 16:31:59 +02:00
Fedor Isakov 7d308cb0e3 Experimental feature: Rules segmentation.
The rules index is extended to observe the segment path a rule belongs to.
An occurrence is bound to the rule that activated it and thus has an
associated segment path.
Rules to be picked for activation can be selected on the basis
of matched segment path.
2019-09-27 21:59:58 +02:00
Fedor Isakov 6b2a14511f A little documentation for RuleMatcher. 2019-09-27 21:59:57 +02:00
Fedor Isakov d5bdcc971f Remove accidental modules from the project. 2019-09-27 21:59:57 +02:00
Fedor Isakov 3ff016d989 Optimizing rule matching algorithm for performance. 2019-09-23 11:27:54 +02:00
Fedor Isakov b8cf79e8e2 Renamed JB SDK to JB JDK 2019-09-23 11:27:54 +02:00
Grigorii Kirgizov 0f1460bb67 Add typechecking of array literals handling nested literals
Array literals always belong to some variable decl and their elements
are recursively checked against declared component type [JLS 10.6].
2019-09-11 13:24:01 +03:00
Fedor Isakov 1c61352068 Bump up reactor lib's version to 0.9.13. 2019-09-10 13:21:07 +02:00