-
-
Notifications
You must be signed in to change notification settings - Fork 194
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 resource expression calculation by removing volatile cache #3900
Conversation
@petschki thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
@jenkins-plone-org please run jobs |
@jenkins-plone-org please run jobs |
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.
I agree with this approach. While you were working on this, I did some timings as well:
- With the current (6.0.9) way, rendering both resource viewlets takes about 0.002 seconds total. Expressions do not work.
- With the previous PR it is a bit more due to a not effective request cache key, but with a fix for that it is about the same. Expressions work, but memory usage increases.
- With the current PR it becomes about 0.005, so it takes longer. Expressions work. Memory usage decreases (very) slightly because the volatile cache is gone. The code is easier.
All in all, I prefer this PR. Thanks!
Let's wait a bit till others have reviewed it as well.
Side note: most likely, on a production site, the resource viewlets are calculated once on a context, and then the html of the page is cached in Varnish or similar, at least for anonymous visitors. So it does not matter too much if calculating these viewlets takes a bit longer.
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
This really does what is expected, so +1
Optimizations:
Render time could be improved just caching the single webresource.render() method, using the registry modification time (_RESOURCE_REGISTRY_MTIME), if there's no condition.
99% of the resources has no condition, so we can cache the render() method. This method take most of the time on creating the path. The path does not depends on anything, it is always the same.
Maybe we've to check if the RAM cache here:
cache = queryUtility(ram.IRAMCache) |
for cooked_expressions but I think they are not used at all.
@petschki Please do the same for 6.1 |
will do 😉 |
continued from here #3844 (comment)