Skip to content

Simplify Eventgen #6188

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

Merged
merged 7 commits into from
Dec 19, 2024
Merged

Conversation

contificate
Copy link
Contributor

This is a small effort to simplify the code within the Eventgen module. The previous style is very unwieldy and makes the file appear more complicated on the surface than it really is.


Passes BVT+BST (209475) but would appreciate review comments as I've dropped the potential for stdout logging in some places (easy to add back) and added commentary that may not be fully accurate.

Colin James added 2 commits December 17, 2024 08:56
Precompute a table of object names for which events should be
propagated. This avoids the list querying done every time the database
queues an event.

Signed-off-by: Colin James <colin.barr@cloud.com>
Signed-off-by: Colin James <colin.barr@cloud.com>
@contificate
Copy link
Contributor Author

contificate commented Dec 17, 2024

It's worth noting that I'm unsure of how solid is_valid_ref is as a predicate. On the surface, it appears as though you can emit false modify events. It may not have any functional effect on the program, as a modify event with a current snapshot already in the client's cache (i.e. no change) is redundant, but it may want to use the actual schema in future. Perhaps I'm wrong, I just think querying a written value as potentially being a reference - with no regard to the actual schema (e.g. is the written field a reference type in datamodel) may have odd, but benign, side effects.

@contificate contificate marked this pull request as ready for review December 17, 2024 09:12
Colin James added 5 commits December 18, 2024 08:10
Signed-off-by: Colin James <colin.barr@cloud.com>
Signed-off-by: Colin James <colin.barr@cloud.com>
Signed-off-by: Colin James <colin.barr@cloud.com>
Signed-off-by: Colin James <colin.barr@cloud.com>
To avoid recomputing the symmetric closure several times during module
initialisation for Eventgen, we introduce a hashtable that stores the
relation.

Signed-off-by: Colin James <colin.barr@cloud.com>
@contificate contificate force-pushed the private/cbarr/misc-events branch from 39ffcb6 to d622dd8 Compare December 18, 2024 08:12
(object, field) *)
relate p p' ; relate p' p
in
Dm_api.relations_of_api api |> List.iter close ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log the size of this table to get an idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should comprise twice as many entries as is in Datamodel.all_relations - which is few in the great scheme of things. I think it's unimportant in the grand scheme of things - the old code was fine as well.

Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes make the Eventgen module a lot easier to read. And reviewing this PR was a good opportunity to actually learn and understand what it does!

I can't help but think that all this relation checking is unnecessarily duplicated between the database itself and the event system. As the database automatically updates the fields for the "other" side of relations, why can't it call the event callback for each of those?

@robhoes robhoes added this pull request to the merge queue Dec 19, 2024
Merged via the queue into xapi-project:master with commit 4cbacdb Dec 19, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants