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.
I found there is a performance issue for filter.module.
As we know check_markup() is a common function and be always called by many other field modules for text sanity check. so i think we can remove all of those disabled filters for check_markup(), it can save a lot of performance for DRUPAL project.
Please see the patch file. Thanks!
Comment | File | Size | Author |
---|---|---|---|
#34 | check-markup-should-not-apply-disabled-filter-list-format-2310765-18.patch | 4.11 KB | @James |
Comments
Comment #1
nevets CreditAttribution: nevets commentedThose filters which is disabled should not be listed sometimes.
is not very specific about what part of the UI this would impact. If one does not list a disabled filter, how do they enable it?Comment #2
@James CreditAttribution: @James commentedYes, i understand your mean, but i won't change any other callers, except check_markup(), and with the new parameter.
Comment #3
nevets CreditAttribution: nevets commentedWithout any benchmarking, this is not a major issue. Changing check_markup() would be an API change.
Comment #4
@James CreditAttribution: @James commentedComment #5
@James CreditAttribution: @James commentedComment #6
@James CreditAttribution: @James commentedComment #7
@James CreditAttribution: @James commentedComment #8
@James CreditAttribution: @James commentedComment #10
@James CreditAttribution: @James commentedComment #11
@James CreditAttribution: @James commentedComment #15
@James CreditAttribution: @James commentedWhy does the patch test failure?
Comment #16
@James CreditAttribution: @James commentedComment #18
joachim CreditAttribution: joachim commentedThis is a change to a function signature -- needs documentation change to match.
Also removing random tags.
Comment #19
@James CreditAttribution: @James commentedThanks @joachim. I have updated and improved something.
Comment #20
@James CreditAttribution: @James commentedComment #22
joachim CreditAttribution: joachim commentedIt's occurred to me that changing the name of a static is technically changing the API -- other parts of the core or contrib may be clearing this static. So I don't think that's going to work.
Overall, how much of a performance gain is this going to produce? How often, typically, are filters disabled in a format?
Comment #23
David_Rothstein CreditAttribution: David_Rothstein commentedI don't understand the proposed performance gain either, especially since check_markup() already has code to avoid processing disabled filters (as it must; otherwise it would be a huge bug if disabled filters were being applied to the text):
(notice the $filter->status check in the if statement)
So doesn't that mean there is no real performance gain here except for making the foreach() loop a little shorter (which is a very tiny micro-optimization)? There would also be fewer filters loaded from the database, I suppose; however, that is offset by the fact that there are now two static caches within filter_list_format() rather than one, so in some cases there would be an extra database query per page request that was never there before.
Comment #24
@James CreditAttribution: @James commentedHi All,
Thanks for your feedbacks!
As I know this functionality is called frequently and I had checked it with XDebug, now i can not remember the calls but it is not small number. I'm not sure the patch would effect much for a simple Drupal project. but for us, we have a lot of fields in content type of our project.
To test it first step, we need clean static caches and memcache data, then try to access the edit page, you will see it in the debug log.
Comment #25
@James CreditAttribution: @James commentedComment #27
@James CreditAttribution: @James commentedComment #28
@James CreditAttribution: @James commentedComment #30
@James CreditAttribution: @James commentedComment #32
@James CreditAttribution: @James commentedComment #34
@James CreditAttribution: @James commentedHow come i can not make this patch passed by simpletest? I have converted it for unix by dos2unix.