Repository navigation
Add hyperfine benchmarks for individual improvements based on UPGRADING and NEWS - #1
Merged
Merged
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.
Farmed UGPRADING and NEWS for performance immprovements, generated benchmarks for hyperfine for each example, and a script around them. Results on our last Hetzner run:
str_repeat_onestr_repeat($s, 1)returns the input string without copying (#23681)str_padarray_reduce$carry[] = …; return $carry;pattern goes from O(n²) to O(n) (#21340)collator_sort_with_sort_keysCollator::sortWithSortKeys()sizes its buffers to the array instead of allocating 2 × 1 MiB per call (#23504)array_intersectzip_add_from_stringZipArchive::addFromString()no longer copies the content (#20497)mb_str_padmb_str_pad()pads by doubling copies (#23667)addcslashesprintfprintf()with only%s/%dis compiled into string interpolation (#19658); this only applies inside functionsarray_sum_productarray_sum()/array_product()(#21787)first_class_callablefoo(...)are cached instead of allocated each time (#19863)array_unshiftclosure_staticstatic fnclosures without captures (RFC); this only applies inside functionspathinfopathinfo()with a singlePATHINFO_*flag skips the components that weren't requested (#23726)sort_single_elementasymmetric_visibilityprivate(set)/protected(set)check is cached for writes (#22709)preg_replace_callback$matchesin the callback no longer copies the array (#21340)intval_binaryintval('0b…', 2)no longer copies the string to strip the prefix (0af87e970)dom_split_textDOMText::splitText()is faster and uses less memory (#20371)array_fill_keysarray_fill_keys()optimized (#20347)new_known_constructornew self(...)(#20259)uri_rfc3986_gettersUri\Rfc3986\Uriobjects no longer re-normalize (#21726)array_columnarray_map_fccarray_map(foo(...), $a)is compiled into aforeachloop (#20934)array_map_multiplearray_map()with several arrays avoids allocations on each iteration (79adb01bf)array_walkvm_stack_recursionjson_decodestream_copy_to_socketstream_copy_to_stream()from file to socket usessendfile()(#20399); no difference in this runarray_map_fcc_strictarray_map()→foreachrewrite is disabled understrict_types=1(#23889)json_encodeJSON_PRETTY_PRINTindentation (#21474); no gain measuredstr_splitstr_split()is optimized, especially for length 1 (#20419); this run used the old snippet, which OPcache evaluates at compile timeWhat stands out:
array_reduce,array_intersect,str_padandstr_repeat($s, 1)all show the large speedups the PRs claimed. Zip and Collator also improved much more than I expected.closure_static: 1.06× here, against about 80% faster in the PR.array_map_fcc: 1.16× here, against 1.11× without JIT and 1.77× with the tracing JIT in the PR. A run withJIT=tracingwould test that claim.sort_single_element: the 8.5 times were very noisy (±184 ms). In the earlier pre-flight it was 631 → 404 ms.strict_typescontrol works:array_map_fcc_strictshows no gain, which confirms the rewrite is off understrict_types=1.stream_copy_to_socket(0.82×): the new sendfile path is slower here, though the PR says file-to-socket gains the most. That could be specific to Docker or arm64, so it needs re-running on the bench machine before anything goes in the post.json_encode(0.93×): the spread is large, so this may be noise, but 8.6 was supposed to be faster.vm_stack_recursion(0.96×): no improvement. The heap is probably not fragmented enough to trigger the slow path in this VM. The snippet may need more memory pressure on the real machine.json_decodeis neutral: the error-location feature added no measurable cost on successful decodes.For blog numbers, run it on the php-benchmarks machine, pinned to one CPU with turbo boost off.