Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Coming from #639974-6: Speed up element_children() using array_multisort()
By optimizing this, I can cut over 300ms off of a drupal front page load on our test servers.
Comment | File | Size | Author |
---|---|---|---|
#9 | drupal-optimize-element_children-1345204-9.patch | 779 bytes | mikeytown2 |
#6 | drupal-optimize-element_children-1345204-5.patch | 596 bytes | mikeytown2 |
#1 | drupal-optimize-element_children-1345204-1.patch | 598 bytes | mikeytown2 |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedComment #2
mikeytown2 CreditAttribution: mikeytown2 commentedComment #3
Peter Bowey CreditAttribution: Peter Bowey commentedQuery: How does this patch measure up in light of the comments by sun?
See: http://drupal.org/node/639974#comment-3666548
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedThat comment was directed towards 7.x.
This patch flattens out element_children() by in-lining element_child(). Code wise they will always output the same; just element_child doesn't get called thousands of times now.
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedAnother round of optimizations to the code here :)
Stock:
Total Self: 92ms
Total Cumulative: 460ms
element_children() calls: 2,470
Patch #1:
Total Self: 67ms
Total Cumulative: 74ms
element_children() calls: 2,482
This Patch:
Total Self: 39ms
Total Cumulative: 39ms
element_children() calls: 2,482
Comment #7
fabsor CreditAttribution: fabsor commentedI tried this to, and I get an even better return from this, closer to about 800ms on a site with a lot of modules, including vertical tabs and node relationships. This is a pretty extreme example, but there are a lot of those out there.
This is completely unintrusive, so I don't see why we can't get this into core.
Comment #8
Gábor Hojtsy1. Was this already applied to Drupal 7?
2. Can we get some inline documentation about what is going on there? The issue comments explain here what is being inlined, but the code might easy be cryptic after the commit to the uninitiated.
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commentedelement_children() in D7 vs D6 are miles apart from each other, but the call to element_child() has been inlined in the D7 code, so you can say this has already been applied to Drupal 7.
Updated patch to add in a comment about in-lined code.
Comment #10
mikeytown2 CreditAttribution: mikeytown2 commentedMoving back to RTBC as I've only added in comments to the code in question.
Comment #11
mgifford#9: drupal-optimize-element_children-1345204-9.patch queued for re-testing.
Comment #12
mgiffordIt's been RTBC for 2 years, but don't see this getting into Core for D6.