WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

Description

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 3 years ago.

Download all attachments as: .zip

Change History (7)

andy3 years ago

comment:1 andy3 years ago

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

comment:2 scribu3 years ago

Interesting approach.

comment:3 dd323 years ago

  • Milestone Awaiting Review deleted

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

comment:4 andy3 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.

comment:5 mikeschinkel3 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?

comment:6 nacin3 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.