-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce transitions between transient and persistent memory and facilitate performance enhancements to fire-rules #268
Comments
I'll say that this is understating the performance impact in certain types of workflows. For one, if durability is being used to save large working memory state to recover later and insert/retract small sets of new changes, the transition from persistent to transient can become a much more significant percentage of runtime performance. I believe the 1-3% number you are discussing here is in a batch workflow where the number of inserts, retracts, and rules to fire is large and somewhat starts to dwarf the time it takes to transition the working memory from persistent to transient and back. |
I concur that workflows that retract and insert facts from sessions with lots of facts already in them would likely be harder hit. Unfortunately I don't have a good way to gather numbers on those particular use-cases though at the moment. |
Currently when a user wishes to retract some facts, insert other facts, and then fire the rules the user must do something like
As a result there are 3 transitions between transient and persistent memory. #184 improved performance for our use cases with large numbers of facts and Rete operations overall, but it did increase the cost of these transitions. On average, I've seen us spend 1-3% of runtime in these transitions, which while not huge is not insignificant.
We can cut this down to a single transition by caching the insertions and retractions and only actually executing them when fire-rules is called. By using a Clojure persistent data structure for this cache we can efficiently maintain the existing semantics around insert and retract returning new sessions. This also has the benefit of giving fire-rules visibility to and control of the insert and retract operations, which facilitates adding options to control the performance of the Rete operations. For example, it would facilitate the enhancements discussed at #249. There was some discussion on this in relation to that enhancement at WilliamParker@af97744#commitcomment-20782287 The API I'm envisioning there would then look something like
on top of the changes proposed in this issue.
The main downsides I see are
The text was updated successfully, but these errors were encountered: