Repository navigation
zend_memnstr: Use a compact Sunday shift table for short needles - #25115
Open
ArtUkrainskiy wants to merge 1 commit into
Open
ArtUkrainskiy wants to merge 1 commit into
ArtUkrainskiy wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I use a 256-byte Sunday shift table instead of a 1024-byte table for short needles. The PHP path selects it for 9–31-byte needles with at least 1024 bytes of haystack remaining. This reduces table initialization. The maximum shift is 32. Comparisons and shifts stay the same. Longer needles keep the integer table through a separate helper.
I measured saved application fixtures on Ryzen 9 5950X and Core i7-13700H. These are warmed, repeated PHP operations, not application throughput measurements. Moderation checks 12 phrases on a miss and stops at the seventh phrase on a hit.
Seven Intel cases slowed down in both the primary series and a fresh replication. Four Russian moderation cases at 64 KiB took +2.9–3.8% more time with Clang 18 in replication. Three HTML
str_ireplacereplacement lengths took +3.6–4.1% more time with Clang 20.A synthetic 64-byte-needle search takes about 31% more time on AMD/GCC 15 through the integer-table path. The causes remain unresolved.
The selected product cases below show primary elapsed-time measurements against master at the branch base. Negative means less time. Each compiler column uses its own master. Absolute master time is in microseconds for AMD/GCC 15 only. † marks noisy observations, with separate replications in the report.
strpos, order ID, ~4 KiB, near startsubstr_count, 3480 B, 17 matchesstr_replace, 3480 B, 17 matchesexplode, MIME message, 2878 Bstr_ireplace, HTML, 2422 B, equal-length replacementEach case has five paired process rounds, 500 ms warmup and five approximately 200 ms samples per process. Empty-loop cost is subtracted. Deltas are medians of paired ratios.
All 205 fixtures pass exact expected-output checks on both binaries for all six compiler/machine configurations. ARM64, Windows and 32-bit builds were not measured.
Full report with cases, time, cycles, instructions, A/A controls, raw data and reproduction.