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.
_htmlpurifier_load() unconditionally calls variable_set() to set the current installed version of htmlpurifier. This is called by hook_filter_info(), and due to #993274: Remove double caching logic, hook_filter_info() is called on every request. Drupal 7 has locking for variable_initialize(), which means when the variable cache is cleared on every request, it's equivalent to the site only being able to serve one page per second (or more, depending on how long the lock is held for). Attached patch checks the current version to ensure we only set it if it's changed.
Comment | File | Size | Author |
---|---|---|---|
htmlpurifier_variable_set.patch | 811 bytes | catch | |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedThis patch looks very reasonable - it's certainly very bad practice to variable_set(0 without a check on the current value or in response to some admin action.
Comment #2
paul.lovvik CreditAttribution: paul.lovvik commentedThe patch is clearly written and appears to be right on inspection. I just tested the patch on my local system to try to validate any performance improvement, and was able to do so. My system is a local dev environment, not a full HA architecture, but even so the performance improvement was measurable.
Before the patch, the variable_set call took 1.7% of the request time (measured when saving a node).
After the patch, variable_set was not called, so it reduced the time for the call to 0% of the request time.
In architectures in which the DB is not on the same hardware as the web server, I am certain this difference in performance would be much more pronounced.
Comment #3
ezyang CreditAttribution: ezyang commentedThanks for the patch. I am currently on vacation, so I can't promise a time when I'll put the patch in, but it looks quite reasonable.
Comment #4
ezyang CreditAttribution: ezyang commentedCommitted to 6.x and 7.x. Thanks for the fix.
Comment #6
jcisio CreditAttribution: jcisio commentedI'm having the same issue with this. This is a critical issue so I think it worth a official release (as there is no new release since more than a year).