Skip to content

[PoC] support sorting packed arrays without converting to hashed arrays first - #20408

Draft
ndossche wants to merge 1 commit into
php:masterfrom
ndossche:packed-sort
Draft

[PoC] support sorting packed arrays without converting to hashed arrays first#20408
ndossche wants to merge 1 commit into
php:masterfrom
ndossche:packed-sort

Conversation

@ndossche

Copy link
Copy Markdown
Member

This is a proof-of-concept.

Demo speedup on i7-4790:

<?php$x = range(20, 0);
for ($i = 0; $i < 500000; $i++)
sort($x);
var_dump($x);
Benchmark 1: ./sapi/cli/php x.php Time (mean ± σ): 123.2 ms ± 3.0 ms [User: 119.5 ms, System: 2.6 ms]
Range (min … max): 119.2 ms … 134.1 ms 24 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 176.8 ms ± 2.5 ms [User: 173.9 ms, System: 2.1 ms]
Range (min … max): 174.3 ms … 183.2 ms 17 runs
Summary
./sapi/cli/php x.php ran
1.44 ± 0.04 times faster than ./sapi/cli/php_old x.php

@jmarble

Copy link
Copy Markdown

@ndossche Just wanted to say thanks for sharing this PoC -- I was able to reproduce the ~1.4x speedup. I also tried merging your changes into my fix branch for SORT_REGULAR (see PR) and I reran your microbenchmark and saw the speedup improve to ~1.7x.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ndossche@jmarble