[PATCH] PowerPC:strrchr() optimization
Rajalakshmi Srinivasaraghavan
raji@linux.vnet.ibm.com
Fri Feb 14 09:16:00 GMT 2014
On 02/12/2014 11:04 PM, OndÅej BÃlka wrote:
> On Mon, Feb 10, 2014 at 11:43:09AM +0530, Rajalakshmi Srinivasaraghavan wrote:
>> Hi All
>>
>> This patch optimizes strrchr() for ppc64. I have attached the benchtest
>> output to show the performance improvement.This is coded with strchr.S as reference and uses
>> cmpb instruction for speed improvement.
> Hi,
>
> There is one thing to check as strrchr could be genericaly implemented
> by other primitives.
>
> I send a patch for that, could you check how does that compare?
>
> https://sourceware.org/ml/libc-alpha/2013-10/msg00201.html
>
> Benchmarking strrchr is bit tricky as performance depends on frequency
> of searched character. I did profiling and most common usecase is
> finding trailing / in pathnames. Typically a result is between 10 and 20
> characters from start. See following for more statistic.
>
> http://kam.mff.cuni.cz/~ondra/benchmark_string/i7_ivy_bridge/strrchr_profile/results_gcc/result.html
>
>
>
Hi
I have applied your changes in strrchr.c and modified the benchtest to
search '/' character (with more than one occurances in various positions).
Proposed ppc64 optimization is still running better than default. I have
attached the results.
--
Thanks
Raji
-------------- next part --------------
raji@bns:~/build1> /home/raji/build1/benchtests/bench-strrchr
simple_strrchr __strrchr_power7 __strrchr_ppc
Length 2048, pos is 32, alignment in bytes 0: 892.25 108.547 195.688
Length 2048, pos is 32, alignment in bytes 1: 892.234 108.156 197.078
Length 2048, pos is 64, alignment in bytes 0: 891.938 108.297 193.531
Length 2048, pos is 64, alignment in bytes 2: 1010.48 108.422 193.75
Length 2048, pos is 128, alignment in bytes 0: 892.047 107.844 192.172
Length 2048, pos is 128, alignment in bytes 3: 892.359 107.109 191.25
Length 2048, pos is 256, alignment in bytes 0: 897.688 124.484 195.625
Length 2048, pos is 256, alignment in bytes 4: 897.688 115.469 190.75
Length 2048, pos is 512, alignment in bytes 0: 900.781 122.969 172.922
Length 2048, pos is 512, alignment in bytes 5: 900.859 123.312 173.75
Length 2048, pos is 1024, alignment in bytes 0: 903.328 133.969 150.25
Length 2048, pos is 1024, alignment in bytes 6: 892.016 114.766 151.25
Length 2048, pos is 2048, alignment in bytes 0: 889.328 105.75 197.047
Length 2048, pos is 2048, alignment in bytes 7: 889 106.672 197
Length 256, pos is 64, alignment in bytes 1: 120.641 23.375 32.5469
Length 256, pos is 64, alignment in bytes 1: 117.875 22.0625 32.9062
Length 256, pos is 64, alignment in bytes 2: 117.953 21.8438 32.7031
Length 256, pos is 64, alignment in bytes 2: 118 21.5 31.9219
Length 256, pos is 64, alignment in bytes 3: 124 26.1562 32.25
Length 256, pos is 64, alignment in bytes 3: 118.172 21.9219 32.25
Length 256, pos is 64, alignment in bytes 4: 118.25 21.75 32.1875
Length 256, pos is 64, alignment in bytes 4: 121.047 23.625 32.25
Length 256, pos is 64, alignment in bytes 5: 122.156 24.2812 38.9375
Length 256, pos is 64, alignment in bytes 5: 117.953 21.8906 39.2969
Length 256, pos is 64, alignment in bytes 6: 126.75 30.7656 38.7812
Length 256, pos is 64, alignment in bytes 6: 120.891 27.3281 38.6406
Length 256, pos is 64, alignment in bytes 7: 117.891 22.1719 38.5
Length 256, pos is 64, alignment in bytes 7: 117.859 21.5938 38.6719
Length 1, pos is 0, alignment in bytes 0: 2.59375 4.42188 7.95312
Length 1, pos is 0, alignment in bytes 0: 2.51562 4.32812 7.21875
Length 2, pos is 1, alignment in bytes 0: 3.23438 4.25 7.17188
Length 2, pos is 1, alignment in bytes 0: 2.79688 4.125 7.10938
Length 3, pos is 2, alignment in bytes 0: 3.625 3.875 7.29688
Length 3, pos is 2, alignment in bytes 0: 3 4.25 7.39062
Length 4, pos is 3, alignment in bytes 0: 7 3.76562 7.21875
Length 4, pos is 3, alignment in bytes 0: 4.14062 3.9375 7.28125
Length 5, pos is 4, alignment in bytes 0: 4.64062 3.90625 7.125
Length 5, pos is 4, alignment in bytes 0: 4 4.15625 7.09375
Length 6, pos is 5, alignment in bytes 0: 5.14062 4.14062 7.34375
Length 6, pos is 5, alignment in bytes 0: 4.5 4 7.14062
Length 7, pos is 6, alignment in bytes 0: 5.98438 3.875 7.1875
Length 7, pos is 6, alignment in bytes 0: 5.25 4.0625 7.375
Length 8, pos is 7, alignment in bytes 0: 6.04688 6.10938 8.34375
Length 8, pos is 7, alignment in bytes 0: 5.26562 5.6875 7.85938
Length 9, pos is 8, alignment in bytes 0: 6.17188 4.5 7.875
Length 9, pos is 8, alignment in bytes 0: 5.6875 4.25 7.85938
Length 10, pos is 9, alignment in bytes 0: 15.1562 5.75 7.4375
Length 10, pos is 9, alignment in bytes 0: 11.0781 5.625 7.6875
Length 11, pos is 10, alignment in bytes 0: 6.92188 4.25 7.51562
Length 11, pos is 10, alignment in bytes 0: 6.57812 4.23438 7.54688
Length 12, pos is 11, alignment in bytes 0: 9.76562 4.25 7.60938
Length 12, pos is 11, alignment in bytes 0: 9.51562 4.1875 7.35938
Length 13, pos is 12, alignment in bytes 0: 8.15625 5.5 7.375
Length 13, pos is 12, alignment in bytes 0: 7.67188 5.51562 7.70312
Length 14, pos is 13, alignment in bytes 0: 7.78125 4.125 7.6875
Length 14, pos is 13, alignment in bytes 0: 7.75 4.14062 7.64062
Length 15, pos is 14, alignment in bytes 0: 8.29688 4.125 7.5
Length 15, pos is 14, alignment in bytes 0: 8.23438 4.20312 7.625
Length 16, pos is 15, alignment in bytes 0: 11.3281 8.10938 8.75
Length 16, pos is 15, alignment in bytes 0: 11.0625 7.40625 8.5
Length 17, pos is 16, alignment in bytes 0: 9.5625 5.95312 8.51562
Length 17, pos is 16, alignment in bytes 0: 9.04688 5.40625 8.10938
Length 18, pos is 17, alignment in bytes 0: 9.70312 5.25 8.10938
Length 18, pos is 17, alignment in bytes 0: 9.5 5.25 8
Length 19, pos is 18, alignment in bytes 0: 10.6875 6.75 8.26562
Length 19, pos is 18, alignment in bytes 0: 10.1562 6.04688 8.0625
Length 20, pos is 19, alignment in bytes 0: 13.2031 5.57812 8.32812
Length 20, pos is 19, alignment in bytes 0: 13.0156 5.20312 8.07812
Length 21, pos is 20, alignment in bytes 0: 13.5 5.20312 7.98438
Length 21, pos is 20, alignment in bytes 0: 13.4688 5.25 8.20312
Length 22, pos is 21, alignment in bytes 0: 14.2969 6.34375 8.15625
Length 22, pos is 21, alignment in bytes 0: 14.0312 6.32812 8.25
Length 23, pos is 22, alignment in bytes 0: 14.4219 5.29688 8.04688
Length 23, pos is 22, alignment in bytes 0: 14.3594 5.28125 8.25
Length 24, pos is 23, alignment in bytes 0: 14.7188 7.375 8.85938
Length 24, pos is 23, alignment in bytes 0: 14.75 6.64062 8.5
Length 25, pos is 24, alignment in bytes 0: 16.3906 7 8.76562
Length 25, pos is 24, alignment in bytes 0: 15.3438 6.75 8.45312
Length 26, pos is 25, alignment in bytes 0: 16.375 7.75 8.25
Length 26, pos is 25, alignment in bytes 0: 15.6406 6.07812 8.32812
Length 27, pos is 26, alignment in bytes 0: 16.1875 5.75 8.34375
Length 27, pos is 26, alignment in bytes 0: 16 5.89062 8.29688
Length 28, pos is 27, alignment in bytes 0: 16.8594 6.84375 8.14062
Length 28, pos is 27, alignment in bytes 0: 16.75 6.59375 8.28125
Length 29, pos is 28, alignment in bytes 0: 17.4688 7.01562 8.26562
Length 29, pos is 28, alignment in bytes 0: 16.9531 5.70312 8.375
Length 30, pos is 29, alignment in bytes 0: 17.2812 5.65625 8.28125
Length 30, pos is 29, alignment in bytes 0: 17.2969 5.65625 8.39062
Length 31, pos is 30, alignment in bytes 0: 18.0781 6.5625 8.34375
Length 31, pos is 30, alignment in bytes 0: 17.9531 6.60938 8.28125
Length 32, pos is 31, alignment in bytes 0: 18.3438 7.75 10.25
Length 32, pos is 31, alignment in bytes 0: 18.1094 6.75 10
Length 2048, pos is 32, alignment in bytes 0: 892.375 109 195.516
Length 2048, pos is 32, alignment in bytes 1: 891.844 107.75 195.328
Length 2048, pos is 64, alignment in bytes 0: 892.281 108.297 194.156
Length 2048, pos is 64, alignment in bytes 2: 892.25 107.25 193.75
Length 2048, pos is 128, alignment in bytes 0: 891.906 107.984 190.984
Length 2048, pos is 128, alignment in bytes 3: 895.016 109.5 193.422
Length 2048, pos is 256, alignment in bytes 0: 892.406 113.531 185.297
Length 2048, pos is 256, alignment in bytes 4: 894.875 116.016 185.328
Length 2048, pos is 512, alignment in bytes 0: 897.75 123.109 173.391
Length 2048, pos is 512, alignment in bytes 5: 898 127.672 173.484
Length 2048, pos is 1024, alignment in bytes 0: 897.906 124.75 150.812
Length 2048, pos is 1024, alignment in bytes 6: 894.953 121.922 150.766
Length 2048, pos is 2048, alignment in bytes 0: 889.141 106.062 196.938
Length 2048, pos is 2048, alignment in bytes 7: 889.109 106.484 195.094
Length 256, pos is 64, alignment in bytes 1: 120.938 23.8281 39.1875
Length 256, pos is 64, alignment in bytes 1: 118.172 21.8125 39
Length 256, pos is 64, alignment in bytes 2: 118.203 22.0312 38.6094
Length 256, pos is 64, alignment in bytes 2: 118.25 21.9219 38.75
Length 256, pos is 64, alignment in bytes 3: 118.25 22 38.3438
Length 256, pos is 64, alignment in bytes 3: 118 21.75 39.0469
Length 256, pos is 64, alignment in bytes 4: 120.922 27.25 38.7344
Length 256, pos is 64, alignment in bytes 4: 117.859 21.9219 38.9844
Length 256, pos is 64, alignment in bytes 5: 120.75 23.6719 39.25
Length 256, pos is 64, alignment in bytes 5: 117.75 21.9531 38.9062
Length 256, pos is 64, alignment in bytes 6: 117.75 21.9531 39.1094
Length 256, pos is 64, alignment in bytes 6: 120.781 24.0312 38.75
Length 256, pos is 64, alignment in bytes 7: 120.859 24.3594 38.3906
Length 256, pos is 64, alignment in bytes 7: 118.109 22.0312 38.75
Length 1, pos is 0, alignment in bytes 0: 2.5 4.39062 7.64062
Length 1, pos is 0, alignment in bytes 0: 2.39062 4.35938 7.34375
Length 2, pos is 1, alignment in bytes 0: 2.71875 4.03125 7.39062
Length 2, pos is 1, alignment in bytes 0: 2.75 3.98438 7.25
Length 3, pos is 2, alignment in bytes 0: 3.23438 3.82812 7.17188
Length 3, pos is 2, alignment in bytes 0: 3 4 7.29688
Length 4, pos is 3, alignment in bytes 0: 4.03125 3.79688 7.21875
Length 4, pos is 3, alignment in bytes 0: 3.9375 3.98438 7.375
Length 5, pos is 4, alignment in bytes 0: 4.25 3.89062 7.21875
Length 5, pos is 4, alignment in bytes 0: 3.76562 4.1875 7.21875
Length 6, pos is 5, alignment in bytes 0: 5 4 7.15625
Length 6, pos is 5, alignment in bytes 0: 4.57812 4 7.20312
Length 7, pos is 6, alignment in bytes 0: 5.75 3.875 7.20312
Length 7, pos is 6, alignment in bytes 0: 5.17188 3.92188 7.04688
Length 8, pos is 7, alignment in bytes 0: 5.75 5.4375 8.09375
Length 8, pos is 7, alignment in bytes 0: 5.25 5.25 7.75
Length 9, pos is 8, alignment in bytes 0: 6 4.4375 7.60938
Length 9, pos is 8, alignment in bytes 0: 5.71875 4.14062 7.53125
Length 10, pos is 9, alignment in bytes 0: 15.1406 5.5 7.5
Length 10, pos is 9, alignment in bytes 0: 11.25 5.6875 7.64062
Length 11, pos is 10, alignment in bytes 0: 6.75 4.23438 7.5
Length 11, pos is 10, alignment in bytes 0: 6.5 4.10938 7.5625
Length 12, pos is 11, alignment in bytes 0: 19.5 5.5 7.32812
Length 12, pos is 11, alignment in bytes 0: 9.71875 4.1875 7.46875
Length 13, pos is 12, alignment in bytes 0: 9.95312 5.5 7.39062
Length 13, pos is 12, alignment in bytes 0: 9.76562 5.4375 7.73438
Length 14, pos is 13, alignment in bytes 0: 7.8125 4.125 7.64062
Length 14, pos is 13, alignment in bytes 0: 7.75 4.23438 7.70312
Length 15, pos is 14, alignment in bytes 0: 8.29688 4.1875 7.25
Length 15, pos is 14, alignment in bytes 0: 8.25 4.15625 7.75
Length 16, pos is 15, alignment in bytes 0: 11.3438 8.78125 8.75
Length 16, pos is 15, alignment in bytes 0: 11.1094 7.21875 8.4375
Length 17, pos is 16, alignment in bytes 0: 9.3125 5.67188 8.375
Length 17, pos is 16, alignment in bytes 0: 9 5.40625 8.10938
Length 18, pos is 17, alignment in bytes 0: 9.625 5.26562 8.25
Length 18, pos is 17, alignment in bytes 0: 9.4375 5.48438 8.07812
Length 19, pos is 18, alignment in bytes 0: 12.375 6.14062 8.01562
Length 19, pos is 18, alignment in bytes 0: 12.2812 6.09375 8.25
Length 20, pos is 19, alignment in bytes 0: 13.2344 5.34375 8
Length 20, pos is 19, alignment in bytes 0: 13.0156 5.1875 8
Length 21, pos is 20, alignment in bytes 0: 13.4062 5.25 8.25
Length 21, pos is 20, alignment in bytes 0: 13.5469 5.32812 8.03125
Length 22, pos is 21, alignment in bytes 0: 15.25 6.25 8.20312
Length 22, pos is 21, alignment in bytes 0: 14.1094 6.0625 7.98438
Length 23, pos is 22, alignment in bytes 0: 14.2812 5.45312 8.23438
Length 23, pos is 22, alignment in bytes 0: 14.3594 5.25 8.26562
Length 24, pos is 23, alignment in bytes 0: 14.7344 6.70312 9
Length 24, pos is 23, alignment in bytes 0: 14.7656 6.40625 8.5625
Length 25, pos is 24, alignment in bytes 0: 15.5469 6.85938 8.45312
Length 25, pos is 24, alignment in bytes 0: 15.375 6.5625 8.21875
Length 26, pos is 25, alignment in bytes 0: 15.625 6.125 8.46875
Length 26, pos is 25, alignment in bytes 0: 15.5469 5.84375 8.46875
Length 27, pos is 26, alignment in bytes 0: 16.125 5.75 8.25
Length 27, pos is 26, alignment in bytes 0: 16 5.75 8.39062
Length 28, pos is 27, alignment in bytes 0: 18.1719 6.75 8.25
Length 28, pos is 27, alignment in bytes 0: 16.6719 6.34375 8.46875
Length 29, pos is 28, alignment in bytes 0: 17.0312 5.90625 8.5
Length 29, pos is 28, alignment in bytes 0: 17 5.82812 8.5
Length 30, pos is 29, alignment in bytes 0: 17.3125 5.70312 8.48438
Length 30, pos is 29, alignment in bytes 0: 17.4062 5.75 8.4375
Length 31, pos is 30, alignment in bytes 0: 18.8125 6.64062 8.25
Length 31, pos is 30, alignment in bytes 0: 18 6.57812 8.1875
Length 32, pos is 31, alignment in bytes 0: 18.25 6.85938 10.5
Length 32, pos is 31, alignment in bytes 0: 18.2656 6.76562 9.92188
More information about the Libc-alpha
mailing list