Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#18404 closed enhancement (maybelater)

Reorganize rewrite_rules into a tree of strings and patterns

Reported by: andy Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Rewrite Rules Keywords:
Focuses: Cc:


At WordCamp San Francisco 2011 (WCSF2011) we discussed optimizing wp::parse_request by converting the flat array of rewrite_rules into a tree by inspecting common prefixes. The proof-of-concept code performed on average about 1ms faster per parse_request. Core team decided to shelve the idea as the added complexity is hard to justify with a 1-2% speed improvement.

The attached patch is a snapshot of the code as it stood on my wordpress.com sandbox during speed testing. The script treetest.php was run from wpsh.

Attachments (1)

18404.diff (10.0 KB) - added by andy 7 years ago.

Download all attachments as: .zip

Change History (7)

7 years ago

#1 @andy
7 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

#2 @scribu
7 years ago

Interesting approach.

#3 @dd32
7 years ago

  • Milestone Awaiting Review deleted

It's surprising how fast anchored regular expressions are sometimes..

#4 @andy
7 years ago

I should clarify that this made wp::parse_request() 30% faster on average with an original rewrite_rules array of about 100 rules. The smaller improvement of 1-2% quoted above applies to the overall page load time.

#5 @mikeschinkel
7 years ago

  • Cc mikeschinkel@… added

How much faster is it when used on sites with lots of custom post types and/or with plugins like BuddyPress as opposed to just the default use-case?

#6 @nacin
7 years ago

If I recall correctly, it scaled rather linearly, so you're only looking at 1-3ms total even with a few hundred complex rules. Given that core is a few hundred times that, it didn't seem worth it for now. The anchored regexps are blazing fast.

But posting it to Trac might mean that someone digs it up in a few years and comes up with some other brilliant idea to rework the system.

Note: See TracTickets for help on using tickets.