The views output and result caches have giant data blobs. For example, turn on Time based cache for Recent Comments block and enable that block You will see that the results cache has full comment entities in it (including fields, ...). If you inspect the output cache, it has all of that plus a View object with lots more stuff.
Not that we have entity load cache, I would think we can just cache ids.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | interdiff-2157777-26.txt | 1.35 KB | damiankloip |
| #27 | 2157777-26.patch | 4.79 KB | damiankloip |
| #25 | interdiff-2157777-25.txt | 776 bytes | damiankloip |
| #25 | 2157777-25.patch | 4.08 KB | damiankloip |
| #22 | 2157777-22-tests-only-FAIL.patch | 1.85 KB | damiankloip |
Comments
Comment #1
dawehnerWe have to cache basically the result coming from the DB which might be just entity IDs but could be arbitrary additional values.
We should though throw away the loaded entities and reload them on cache loading.
Comment #2
dawehnerWe could do something like that.
Comment #3
damiankloip commentedYes, I would be pretty happy with this approach. I think it would need to be like this instead though, so we don't assign the view result to NULL every time. But yeah, I guess it was just the idea there mainly.
It's a good point that we now should not really need to cache full entities. We will probably want to measure the performance difference here, with the additional queries needed 'n' all.
Comment #4
dawehnerHa
Comment #5
damiankloip commentedAlso, re-titling/purposing. As making changes to the output cache will need alot more discussion, and is a much more complexed topic :)
The patch we have here is fine for the result cache.
Comment #6
damiankloip commentedComment #7
moshe weitzman commentedI tested this patch and the data is *much* briefer now. Thanks for the quick turnaround!
Comment #8
dries commentedPlease add a comment explaining (1) what we are doing here and (2) why. It's not really clear from the phpDoc what 'preparing' means.
Comment #9
damiankloip commentedhmm ok, That bit of code you've pasted seems pretty self explanatory to me tbh. The code is self descriptive (clone x, unset(x,y), assign). Did you also see the param docs? I think they complete the picture too:
Here is a comment to that effect anyway.
Comment #10
dawehnerBack to RTBC.
Comment #11
catchHmm. Could we not load the entities after the cache_set()? Then it wouldn't be necessary to remove them from the cache entry and add them back. Thinking about other stuff than loaded entities which might get in here at some point.
I didn't look at how feasible that is, if the answer is 'not at the moment', then OK but could do with a follow-up.
Comment #12
damiankloip commentedI think that's a 'not at the moment' I'm afraid. cacheSet is called from ViewExecutable after query->execute() is called, it's in there that the rows are loaded, and loadEntities() is also called etc...
Comment #13
dawehnerI kind of like the fact that the query plugin is not aware of caching at the moment. The question on the other hand is whether the view executable should instead call the load entities method, as even only the query plugin will know exactly how to load them, it should not need to know when to load them.
This though is indeed more a follow up.
Comment #14
webchickBack to catch!
Comment #15
catchOK that's fair enough. Committed/pushed to 8.x, thanks!
Comment #16
damiankloip commentedGreat. Thanks, and merry christmas, catch.
Comment #18
damiankloip commentedReopening, looks like this never actually got committed :D
So here is a reroll. Good place to start.
Comment #19
dawehnerI kinda have the feeling we should test that we don't serialize the _entity components.
Comment #20
berdirThe entities themself are aren't even that much of a problem, they are pretty well optimized, although caching separately could result in cache inconsistencies if they are updated in the meantime. The biggest problem is really the ->view property, that serialized the whole view.
Comment #21
moshe weitzman commentedComment #22
damiankloip commentedQuick test
Comment #24
wim leersEvidently, this patch works, because it's green (unless
$cache->data['result']is empty, which you also may want to add a preventive assertion for, to prevent future regressions).But how is it possible that the result of
unset()isNULLin one case and the empty array in the other?Comment #25
damiankloip commentedAdded an assertion that results are in the cache, that's a fair point.
This is possible because...serialization.
Try it:
Comment #26
wim leersOh, those are the defaults on
ResultRow. Then that makes sense :)Considering this was RTBC before, and that all that what was missing was more test coverage, I think this is now RTBC again.
Comment #27
damiankloip commentedTalking to berdir on IRC, maybe we should set the values to their original instead of unsettings, but then, maybe we just add a method to call that does this for us.
EDIT: looks like x-post with WIm there. Wim, what do you think about this latest change? re-RTBC? :)
Comment #28
berdirInterdiff looks good to me.
Comment #29
wim leersYep, trivial changes. RTBC+1
Comment #30
damiankloip commentedThanks both.
Comment #31
catchCommitted/pushed to 8.0.x, thanks!
Comment #33
catch