-
Notifications
You must be signed in to change notification settings - Fork 23
refactor: Simplify predicate notification system #348
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
base: main
Are you sure you want to change the base?
Conversation
…d in the same order that they are returned
maartenflippo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should take into account that we do not track predicates becoming false.
| #[derive(Clone, Copy)] | ||
| struct TrackedValue { | ||
| value: i32, | ||
| flags: u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done using EnumSet. It will have the same packing
| impl Debug for TrackedValue { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| f.debug_struct("TrackedValue") | ||
| .field("value", &self.get_value()) | ||
| .field( | ||
| "PredicateTypes", | ||
| &self.get_predicate_types().collect::<Vec<_>>(), | ||
| ) | ||
| .finish() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using enumset, this can be derived
maartenflippo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests to the PredicateTracker
Review re-requested
Currently, the predicate notification system is convoluted and carries a lot of duplicate information with several levels of indirection to reach a specific tracker for a predicate type.
This PR addresses this issue by merging all of these trackers for different types into a single
PredicateTracker, which keeps track of the status of all predicate types at once.To accomodate this, two new
TrailedIntegers are required, which, rather than being moved when a bound is greater (lesser) than or equal to the tracked value, are moved when the bound is strictly greater (lesser) than the tracked value. This allows us to track all of the different predicate types using a single tracker.TODO
Vec<Vec<PredicateType>>to track which predicates are attached to a value.However, we can use 4 bits to store this information more conciselyUsing only 27 bits for representation was too little, so it is now stored as with an additional EnumSet