field_modules_enabled($modules) was added to field.module in 7.14, and really does a number on the speed of an install profile - the result is something like a 2x to 5x slowdown during the module installation batch calls depending on whether or not you are heavily using features modules (e.g. lots of content types and fields being defined).
/**
* Implements hook_modules_enabled().
*/
function field_modules_enabled($modules) {
// Refresh the 'active' status of fields.
field_sync_field_status();
}
This is a big deal for groups like us, who have large install profiles.
From running profiling on the install, this slowdown appears to be just a very large number of operations (repeated module_invoke calls all the way down...) resulting from the field_sync_field_status() call - no one cause leaps out.
If you do this:
/**
* Implements hook_modules_enabled().
*/
function field_modules_enabled($modules) {
// Refresh the 'active' status of fields, but only after an install is
// completed.
if (variable_get('install_task') == 'done') {
field_sync_field_status();
}
}
You end up with speed restored to the 7.12 level, but you you don't get a proper installation - fields are not correctly attached to entities. So further investigation needed here to figure out why this is so much slower than the way it used to work.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | field-system-info-alter-1599146-11.patch | 889 bytes | dcam |
Comments
Comment #1
bojanz commentedAs I said in #1574716: Avoid unnecessary cache rebuilds when creating and updating fields:
That's something we should approach.
Comment #2
exratione commentedAfter some digging, it looks like the issue is spawned by a call to l() of all things, in field_system_info_alter(). That can safely be discarded during install.
A patch is attached.
Comment #3
exratione commentedProfiling with the patch #2 in place, the cost of field_sync_field_status() drops from 4.5s to 0.8s for a batch install call late in our install profile.
I agree that it would be nice to do away with system_rebuild_module_data() call in field_sync_field_status() - that's pretty much all of that 0.8s cost right there.
Comment #4
exratione commentedSee also this item: #1599306: field_sync_field_status() needlessly rebuilds module data, slows down installation dramatically.
Comment #5
mrfelton commentedPatch updated - last one appeared to be corrupt.
Comment #6
swentel commentedLet's fix this in D8 first. Other approach by checking on MAINTENANCE_MODE which makes more sense than relying on a variable. This way, this hook is not fired either on update.php - or any other maintenance mode where this absolutely does not make any sense.
Comment #7
swentel commentedEuh, wrong status
Comment #8
swentel commentedAh man, totally wrong
Comment #9
swentel commentedThis is now used in D8 - also field_modules_installed will be removed once the concept of active and inactive fields is gone in #1503314: Remove the concept of active / inactive (field types, storage) from Field API
Comment #9.0
swentel commentedCorrecting understanding.
Comment #10
jibranaccording to #9.
Comment #11
dcam commentedBackported #8 to D7.