-
Notifications
You must be signed in to change notification settings - Fork 770
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
Optimize get() function in Gdn_Configuration class #7619
Comments
A general observation: But the large majority of configuration calls do not use the array-functionality (e.g. fetching the In fact, I would advocate for making the sub-array functionality more explicit. If you are expecting an array of config values, it should be something like
|
I've done some tests. Around 70% of I also see a lot of repeated calls for Edit: The overall number of calls on a standard install is more around 500 - 1000 for me. Memory caching nonexistent values as mentioned above didn't really make a measurable difference. |
@bleistivt do you have access to our branches other than Master? So far I have 2x speed up on my test home page. |
Looks like my local setup is mostly IO bound. I'll have to try it on a better server to check the speed.
Probably introduced here: Apart from that no problems, everything works the same. |
@bleistivt Sorry for that. I just pushed few updates - should not fail with tAll() anymore |
What's the intended upgrade path? Importing the trait and replacing all Everything up to this point looks pretty safe and didn't break anything for me, so good job. But what about permissions and config values? Plugins sometimes change these mid-request to trigger a certain behaviour. Will this be reflected in the cached version? The data flow to the cache traits is currently unidirectional. How are changes in the source (config, permissions) handled? |
vanilla/library/Garden/Translation.php Line 30 in e52d21f
The translation default isn't used very often (and probably not encouraged anymore?) but shouldn't it be passed along anyway? |
This trick with static cache is to apply where we don't expect data to be changed or generated during php execution. It expects data to exist at the moment php gets request and not changed during the execution. That is one of the reasons why trait seem to be convenient solution. So if we have some config values or translation exist in our environment and we expect them to be "static" during the php code execution - we can apply these traits. I did expect that Permissions are "static". But realized that some permissions are "dynamic/mutable". And when I did try to cache them on very first calls - later some plugins failed because of wrong cached values. I did revert that approach since found some dynamic changes in the code and at the moment I have no solution for those. I hope Configuration has no dynamic/mutable part, but probably I am wrong. That is why I do not apply all this static cache globally but try to apply it locally on some classes and some values I can see and prove are "static" |
Configuration is mutable. Passing I'm closing this for now because If you are in an instance method I would recommend dependency injecting your configuration values with https://docs.vanillaforums.com/developer/framework/dependency-injection/ |
I have around 4K calls to this function.
I doubt that we have to call it that many time and/or we can optimize the performance.
array_key_exists
calls inside that function is clearly detected as one of weak points by blackfireThe text was updated successfully, but these errors were encountered: