Skip to content

[PHP] Retain the next cautious URL match per mapping - #589

Open
adamziel wants to merge 1 commit into
trunkfrom
codex/retain-cautious-url-lookahead
Open

[PHP] Retain the next cautious URL match per mapping#589
adamziel wants to merge 1 commit into
trunkfrom
codex/retain-cautious-url-lookahead

Conversation

@adamziel

Copy link
Copy Markdown
Collaborator

Retains the next URL match already found for each cautious rewrite mapping.

A scan with several mappings previously ran every mapping regexp after every match. Mappings whose next match was later in the text searched the same bytes again on each call. The processor now keeps their relevant captures until the scan reaches them. Captures behind the current byte offset are refreshed, and exhausted mappings stay exhausted. The single-mapping path remains direct because it has no future lookahead to reuse.

For 100 matches of one source URL, the local benchmark measured:

Mappings Before After
1 92.8 µs 93.2 µs
2 342 µs 128 µs
8 1.85 ms 0.20 ms
32 7.90 ms 0.48 ms
64 16.16 ms 0.85 ms

Testing

The URL rewriting suite passes with 364 tests and 2,502 assertions. New cases cover a future mapping retained across repeated earlier matches and a shorter overlapping mapping refreshed after the longer source wins. PHPStan and the coding-standard checks pass for the changed files.

@github-actions

Copy link
Copy Markdown
Contributor

Pull pipeline performance — large-directory

Site: large-directory · 2,000+ plus targeted file-transfer scenarios files · 10,000 posts · 25,000 postmeta · PHP 8.5.9

Stage PR trunk Δ Status Details
playground-sqlite-db-pull 9.73 s 9.41 s ⚪ +322 ms (+3.4%) condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
trunk: condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
playground-sqlite-db-apply 3.58 s 3.58 s ⚪ -2 ms (-0.1%) condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
trunk: condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
Total 13.31 s 12.99 s ⚪ +320 ms (+2.5%)

Numbers carry runner noise; treat single-run deltas as directional, not authoritative.

📈 Trunk performance history — commit-by-commit timeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant