-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
(Performance) ManagedEntities - Only update an entity if its declaration has changed #32345
Open
totten
wants to merge
4
commits into
civicrm:master
Choose a base branch
from
totten:master-mgd-checksum
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
colemanw
reviewed
Mar 12, 2025
colemanw
reviewed
Mar 12, 2025
dc343da
to
9a59ab1
Compare
totten
commented
Mar 12, 2025
9a59ab1
to
0a87580
Compare
0a87580
to
e8f0384
Compare
…pagate The problem becomes apparent in some of the mixin tests. Historically, they were asymptomatic because `ManagedEntities::reconcile()` would cast a very wide net -- and some of the other items in that net would _coincidentally_ flush caches. However, if the reconciliation is more targetted, then we don't get a timely flush.
So far, new test-run is looking better for all scenarios that previously failed. Removing the "Draft" flag. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Generally, the purpose of
ManagedEntities
is to keep a database-record up-to-date with the description in code.This optimization should improve the performance of a typical system-flush/cache-clear. For example, on my local
drupal-clean
build (with ~65 managed entities), the typical runtime ofcv flush
drops from 5.1s to 1.6s.The benefits should be more significant for systems with more managed-entities.
Before
To reconcile, we walk through all the entities and issue API calls (
create
,update
,delete
) to ensure that the database is up-to-date with the declaration.However, during most flushes, there has been no real change in either the entity-declaration or the live-entity. Consequently, the
update
(usually) isn't doing anything useful.After
We only perform an
update
if the entity-declaration has changed in some way.Comments
While working on Upgrader - Ensure rebuildMenuAndCaches() runs with fresh container #32339 with the wmff build, I noticed that
rebuildMenuAndCaches()
was slow -- and that the configuration declared almost 1,000 managed-entities. That's a huge number -- much more thanManagedEntities
was originally designed for. This kind of configuration should see bigger gains.I haven't done very deep testing. I wouldn't be surprised if there are some test-failures. I've only done the quick benchmark.
This does change the interpretation of the
update
policy:always
unmodified
never
The new interpretation still follows the same configuration precedence (e.g.
always
prioritizes canonical-declarations;never
prioritizes local-configuration) -- but it applies enforcement less frequently.What if you want strict enforcement -- i.e. your intent is to strictly prevent edits to the managed-entity?
update=>always
was the closest to doing that, but it was never strict. (You might say it was 66% of the way there.)On a gut-level, I expect there will be some scenarios where one wants to forcibly re-save. But I'm not exactly sure where that ends-up. An advanced flush-option? Something you do for full core-upgrades... but not for intermediate(This has been re-worked. It does a full re-save whenever you upgrade the system, and it does a targeted re-save when you (re)enable an extension.)cv flush
es? I'm not sure For the moment, there's just a discreet PHP flag as a nod in that direction.