Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
configuration entity system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Apr 2014 at 17:25 UTC
Updated:
26 May 2015 at 11:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
berdirSomething like this I think...
Comment #2
yched commentedCode looks good - minor nitpick :
This addition makes the existing comment a bit moot :-)
This does a second pass looking at all existing names, so we still have a chance to avoid parsing all existing contents.
Comment #3
berdirComment #6
jhedstromIndentation error here.
Perhaps this new logic could be moved to another method, something like
filterByIdCondition()(it would simplify theloadRecords()method).This seems tricky to explicitly test since this only alters internal behavior, and the end result from
execute()should be the same as it is now?Comment #7
chx commentedSince entity query is required for mongodb I am considering this work and will chime in:
array_filterwas made for this. Use the switch to create the filter closure and then run array_filter on it. Don't forget to invert the conditions from the current code since current adds but array_filter removes. For eg the<>:Comment #8
yched commented@chx : we can do that. Not sure it's a real legibility win in the end, but why not :-)
Comment #9
chx commentedNow this shows where we need more tests: as I said in #7 we need to invert the conditions and yet it passed.
Comment #10
yched commentedEr - we shouldn't invert the conditions ?
array_filter keeps the array values where the callback returns TRUE.
Thus if the condition is '<>', the callback should return true if the id is !== that the condition value,
etc.
The callbacks as written in the patch are correct AFAICT.
Comment #11
chx commentedOh, of course, I have no idea what I am talking about :/ Sorry!
case '<>':closing brace has an indent error and still needs tests.Comment #12
yched commentedWith tests.
The fact that you can write EntityQueries with STARTS_WITH, CONTAINS... conditions is not added by this patch, so arguably it shouldn't be the job of this patch to add tests for them :-)
What we should be testing is the fact that those conditions are evaluated without loading all the entities, but I'm not sure we can do that.
Comment #13
yched commentedReroll + bump ?
Comment #14
chx commentedLooks good, then.
Comment #15
alexpottI ponder #2430219: Implement a key value store to optimise config entity lookups and how we can make this more generic
Comment #16
yched commented@alexpott: looks related but different - this case here is about conditions on IDs, where optimizing requires no denormalization in storage, and PHP can reduce the set of results before even hitting the db ?
IIRC we do have a couple queries like "select all field config starting with node.article.*", I don't think any denormalization will optimize those ?
Comment #17
alexpottWhat happens if we have two ID conditions in a query?
This comment now seems out of place.
I proposed we do something like the interdiff attached - which we need tests for.
Comment #18
yched commented@alexpott: do you think it's really a case we need to care optimizing ?
If there are several conditions on IDs, we use the first one to restrict the set of records to load, and then the other cnditions are checked on the records. Not sure we really need to do more ?
Comment #19
alexpott@yched in the case of several conditions we're using the last which seems non-obvious to me
Comment #20
berdirThis needs to be rerolled after #2430219: Implement a key value store to optimise config entity lookups got in. Would be great if someone in LA can give it a try to make this work again.
Not sure if the discussion above is still relevant, let's see how the reroll looks like.
Comment #21
alexpott@Berdir your wish is my command :)
Rerolled.
Comment #22
berdirThanks!
So, using the same scenario as #2482295: Rebuilding field map with many bundles/fields is very slow, this is already a huge improvement on the execution time:
So, #2482295: Rebuilding field map with many bundles/fields is very slow is only about twice as fast as this, unlike compared to HEAD, where it is ~25x as fast ;)
For memory usage, I got some really interesting results. I'd expect this to still use more memory, but it actually uses a huge amount less. The reason for that is that even without getFieldMap(), we still have 5 calls to field_entity_bundle_field_info(), and that uses an immense amount of memory.
This, for the same drush script:
#2482295: Rebuilding field map with many bundles/fields is very slow:
So the function uses exactly as much time for 1/100 of the calls, and twice as much memory ;)
But actually, it's perfectly possibly to combine the two patches:
WIN! :)
I think that qualifies as at least major ;)
Comment #23
berdirPatch looks good to me.
I agree with @yched that supporting multiple ID conditions doesn't seem necessary, that seems like an extremely rare use case. But I also agree that it's strange that we actually use the last one to filter. So maybe just add a && !$id_condition to the if and update the comment to say that we use the first id condition to filter down?
Comment #24
yched commented+1 to #23
Also, the rerolled code after after #2247379: Optimize config entity query conditions on ID looks a bit confusing between "condition on names" and "condition on IDs"
(but that might be because I didn't really look into what that other issue was doing)
Comment #25
alexpottFixed #23.
re #24 - a config name is
field.field.block_content.bodyand an ID isblock_content.body. The current code makes this consistent.Comment #26
berdirLooks good to me now :)
Comment #27
jibran:)
Comment #28
berdirNo, I don't think it does.
This is an internal optimization for certain conditions. There's nothing to configure, update or use, so no need to update any change records.
Comment #29
catchCommitted/pushed to 8.0.x, thanks!
Comment #31
catch