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
Fix #5337 - suppress rewrite config in db without changes #5367
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5367 +/- ##
=======================================
Coverage 13.71% 13.71%
=======================================
Files 633 633
Lines 8685 8685
Branches 1337 1337
=======================================
Hits 1191 1191
Misses 6319 6319
Partials 1175 1175
Continue to review full report at Codecov.
|
@MurzNN your commits aren't passing the DCO check, can you please fix this? (You need to sign each commit) |
Now Strapi rewrite all 'plugin_content_manager_configuration_content_types' keys in "core_store" database table on each restart. I add comparison of stored config with generated, and skip unnecessary write config to database, when there are no changes. Signed-off-by: Alexey Murz Korepov <murznn@gmail.com>
@derrickmehaffy, thanks for tip, I fix this. |
key: configurationKey(key), | ||
value: config, | ||
}); | ||
if(JSON.stringify(currentConfig) != JSON.stringify(storedConfig)) { |
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.
Using stringify isn't an efficient way to compare the object. lodash isEqual would be faster for now.
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.
Thanks for tip, I replace JSON.stringify to lodash isEqual
Without the changes that @alexandrebodin mentioned, I tested this against my own project and it dropped the startup time from around |
@@ -37,13 +37,13 @@ const setModelConfiguration = async (key, value) => { | |||
} | |||
}); | |||
|
|||
if(JSON.stringify(currentConfig) != JSON.stringify(storedConfig)) { | |||
if(_.isEqual(currentConfig, storedConfig) == false) { |
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 you please use !_.isEqual(a,b)
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.
fixed
@derrickmehaffy would you mind testing your perfs with the new commit ? |
Signed-off-by: Alexey Murz Korepov <murznn@gmail.com>
Signed-off-by: Alexey Murz Korepov <murznn@gmail.com>
Yup can do, I'll test right now and edit with my findings |
So this is actually about 200ms slower on average compared to previously. No Changes: startup in 4600 And I have not modified my schema at all here. Edit for reference: So all in all this should be saving me 98 writes to the database, and just comparing the ctm schemas. I'll some more logging to determine what queries it is actually running. |
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.
LGTM
Thanks for your PR sir :D |
Now Strapi rewrite all 'plugin_content_manager_configuration_content_types' keys in "core_store" database table on each restart.
I add comparison of stored config with generated, and skip unnecessary write config to database, when there are no changes.
fixes #5367
Signed-off-by murznn@gmail.com