Problem/Motivation
Don't fully understand why yet, but i noticed on our project with redis monitor that there are quite a few identical cache lookups:
"HGETALL" "prefix:data:css:THEME_NAMEenaxHQwg5UBhW9FfRUylgqlvQ43K67H9VuTW3QXt27iZU1"
"HGETALL" "prefix:data:js:THEME_NAMEen:D9AaXzT3MlnOQcjEJMKZEOqJpT9sVkpufRFf2FceqFM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM11"
"HGETALL" "prefix:data:js:THEME_NAMEen:D9AaXzT3MlnOQcjEJMKZEOqJpT9sVkpufRFf2FceqFM11"
There are two unique hashes, the D9A... one is actually all-the-libraries, the NXh hash is an empty array of $libraries_to_load and settings.
Not sure how common this situation is, this also also on 10.4, haven't verified yet if 11.x changes anything.
I'm not sure what this is doing exactly with those assets. Took me a while to find where exactly it's looping, it's in \Drupal\big_pipe\Render\BigPipe::sendNoJsPlaceholders(), which has 23 fragments, all or most seem to be toolbar parts (classic toolbar with admin_toolbar).
Not sure what should be done in this scenario. statically cache the cache? if it's all identical, do we even need to process it or could we somehow return early somewhere?
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3504559-nr-bot.txt | 91 bytes | needs-review-queue-bot |
| #8 | 3504559-nr-bot.txt | 91 bytes | needs-review-queue-bot |
Issue fork drupal-3504559
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3504559-assetresolver-may-load
changes, plain diff MR !11121
Comments
Comment #2
berdirI can reproduce this on 11.x by installing admin_toolbar_tools, but I assume this might also happen if you have lots of placeholders without that.
I can see that this also happens out of the box on standard profile, for example with comments. To reproduce, create an article with a few comments, helps to filter redis monitor to just ":js:" then:
7zukb8t4ZfBhCx251RER8wVVOq1uHT4RK1bzyN is repeated twice and NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM10 three times, that's on an article with 4 comments or so. Adding more comments doesn't directly correlate to the number of repetitions it seems.
Unsure how to proceed on this one. I could add a memory cache or something, but there might be something more useful to be done in this case?
Comment #3
berdirI also tested with #3494354: AssetResolver::getJsAssets cache id doesn't consider attached settings, leads to ajax issues, doesn't really change this.
Comment #4
berdir#3493911: Add a CachedPlaceholderStrategy to optimize render cache hits and reduce layout shift from big pipe is also not helping here, because those placeholders aren't cacheable.
Comment #5
catchI think I tried to get rid of this in #3494354: AssetResolver::getJsAssets cache id doesn't consider attached settings, leads to ajax issues by skipping the cache get on empty libraries altogether, but it is not entirely skippable due to alters etc.
Statically caching result of the cache get only in the case of empty libraries is probably the simplest thing to do here.
Comment #7
berdirInjecting the cache chain now and updated the test. This will of course conflict with several other issues.
Comment #8
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #9
berdirRebased.
Comment #10
catchThis looks great, I don't see anything else to do.
Comment #11
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #12
berdirRebased, minor conflict on CacheTagIsValidCount.
Comment #13
smustgrave commentedAppears to need a rebase
If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #14
berdirRebased and test assertions updated, green again.
Comment #15
smustgrave commentedWill add to my list for tomorrow but since it was previously RTBC wonder if it’s good to go back?
Comment #16
berdirIt should be, nothing changed except performance metric conflicts. One reason I didn't set it back myself is that there are a lot of performance issues right now and it's not as important/big of an impact as some others, but any improvement helps...
Comment #17
smustgrave commentedOkay in that case going to remark it
Comment #19
catchCommitted/pushed to 11.x, thanks!