Moshe found a linear slowdown when using devel generate to create terms in D7:
Attached patch does not fix this, I found the linear slowdown in devel_generate itself, see: #735706: Filesort in term generation.
However, while I was ruling things out, I did manage to find lots to optimize in taxonomy_term_save() itself.
Attached patch does the following:
1. Does not try to delete entries in taxonomy_term_hierarchy which cannot possibly exist.
2. Moves cache_clear_all() to the two submit handlers which update terms, there's no reason to clear the page cache when terms are inserted, or to have page cache clearing embedded in API functions - if I want to batch update a tonne of terms, I should be able to run cache_clear_all() at the end, or leave the stale cache entries for a few minutes even.
3. Removes a bogus check for is_array($term->parent) immediately after we've guaranteed it's an array.
This improves taxonomy_term_save() performance as measured by devel generate from up from 1,300 terms/minute on my laptop to approximated 2100 terms/minute.
Before patch:
catch@catch-laptop:~/www/7$ drush generate-taxonomy 1 20000 --feedback=1000 -d
Completed 1000 terms (1304 terms/min) [50.97 sec, 31.39 MB] [ok]
Completed 1000 terms (1224 terms/min) [99.73 sec, 31.39 MB] [ok]
Completed 1000 terms (1277 terms/min) [146.7 sec, 31.39 MB]
After patch:
catch@catch-laptop:~/www/7$ drush generate-taxonomy 1 20000 --feedback=1000 -d
Completed 1000 terms (2069 terms/min) [34.26 sec, 31.38 MB] [ok]
Completed 1000 terms (2069 terms/min) [63.42 sec, 31.38 MB] [ok]
Completed 1000 terms (2069 terms/min) [92.37 sec, 31.39 MB] [ok]
Completed 1000 terms (2069 terms/min) [121.5 sec, 31.39 MB] [ok]
Completed 1000 terms (2000 terms/min) [150.98 sec, 31.39 MB]
Have not run tests on this.
Comment | File | Size | Author |
---|---|---|---|
#7 | taxonomy_term_save_a_bit_faster.patch | 3.4 KB | catch |
#1 | taxonomy_term_save_a_bit_faster.patch | 4.58 KB | catch |
Comments
Comment #1
catchForgot patch :(
Comment #3
catch#1: taxonomy_term_save_a_bit_faster.patch queued for re-testing.
..Somehow I don't think this is causing mail and javascript system test to fail.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedLooks like a nice cleanup, and bot is green
Comment #5
catch#1: taxonomy_term_save_a_bit_faster.patch queued for re-testing.
Comment #7
catchOther cleanups went in, re-roll. This now only deals with the cache_clear_all() and the is_array().
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedcode looks good. please wait for green before commit
Comment #9
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.