[wp-trac] [WordPress Trac] #58291: Speed up WordPress hooks addition/removal by ~20%

WordPress Trac noreply at wordpress.org
Fri May 12 22:39:38 UTC 2023


#58291: Speed up WordPress hooks addition/removal by ~20%
--------------------------+------------------------------
 Reporter:  bor0          |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+------------------------------

Comment (by bor0):

 Thank you for all the comments and discussions. In the latest patch:

 - Re-introduce `'::'`
 - Remove redundant `if` checks for `::build_unique_id`
 - Add phpdoc to explain that `::build_unique_id` expects a pair, if an
 array

 With the latest patch ran on `mu-plugin.php`, I get these two average
 numbers:

 - Before: 0.2395233392715454
 - After: 0.19285016059875487

 Improvement: ~19.48%

 I believe the biggest benefit comes from switching `spl_object_hash` to
 `spl_object_id`. If we use `spl_object_hash` instead with 58291.5.patch,
 the number averages to 0.23015589714050294 which brings about 3%
 improvement.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58291#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list