[Mono-devel-list] String::Equals Performance

Andreas Nahr ClassDevelopment at A-SoftTech.com
Sun Jul 4 16:00:01 EDT 2004


In Text

Maybe you should change the column "change" to "improvement", because
359,71% improvement just sounds better ;)

Andreas
----- Original Message ----- 
From: "Ben Maurer" <bmaurer at ximian.com>
To: "Andreas Nahr" <ClassDevelopment at A-SoftTech.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Sunday, July 04, 2004 8:19 PM
Subject: Re: [Mono-devel-list] String::Equals Performance


> I decided to write the benchmark myself. Here are some results:
>
> important cpu info:
>
> [benm at 164-99-120-44 benm]$ cat /proc/cpuinfo
> processor       : 0
> vendor_id       : GenuineIntel
> cpu family      : 6
> model           : 9
> model name      : Intel(R) Pentium(R) M processor 1600MHz
> stepping        : 5
> cpu MHz         : 1599.104
>
> (NB: I did this test with the cpuspeed daemon set to not enable
> speedstepping, so my effective cpu speed did not change during the
> test).
>
> [benm at 164-99-120-44 play]$ mono streq.exe
>                 Test:    Current   |    Andreas   |   Change
>               ptr eq:        187   |        127   |  32.09 %
>           length neq:        542   |        390   |  28.04 %
>  10, neq, first char:        311   |        387   | -24.44 %
>   10, neq, last char:        518   |        387   |  25.29 %
>           0 char, eq:        227   |        233   |  -2.64 %
>           1 char, eq:        273   |        245   |  10.26 %
>           2 char, eq:        342   |        260   |  23.98 %
>           3 char, eq:        352   |        274   |  22.16 %
>           4 char, eq:        393   |        287   |  26.97 %
>           5 char, eq:        401   |        304   |  24.19 %
>           6 char, eq:        443   |        323   |  27.09 %
>           7 char, eq:        450   |        337   |  25.11 %
>           8 char, eq:        493   |        351   |  28.80 %
>           9 char, eq:        502   |        369   |  26.49 %
>          10 char, eq:        543   |        387   |  28.73 %
>          11 char, eq:        553   |        402   |  27.31 %
>          12 char, eq:        590   |        417   |  29.32 %
>          13 char, eq:        602   |        435   |  27.74 %
>          14 char, eq:        643   |        451   |  29.86 %
>          15 char, eq:        652   |        468   |  28.22 %
>          16 char, eq:        692   |        410   |  40.75 %
>          17 char, eq:        701   |        421   |  39.94 %
>          18 char, eq:        745   |        438   |  41.21 %
>          19 char, eq:        746   |        453   |  39.28 %
>          20 char, eq:        794   |        467   |  41.18 %
>          40 char, eq:       1312   |        709   |  45.96 %
>          60 char, eq:       1823   |        951   |  47.83 %
>          80 char, eq:       2320   |       1125   |  51.51 %
>         100 char, eq:       2825   |       1361   |  51.82 %
>         150 char, eq:       4182   |       1931   |  53.83 %
>         200 char, eq:       5465   |       2498   |  54.29 %
>         250 char, eq:       6725   |       3076   |  54.26 %
>         300 char, eq:       7995   |       3622   |  54.70 %
>         350 char, eq:       9257   |       4213   |  54.49 %
>         400 char, eq:      10528   |       4676   |  55.59 %
>         450 char, eq:      11786   |       5224   |  55.68 %
>         500 char, eq:      13060   |       5796   |  55.62 %
>         600 char, eq:      15582   |       6935   |  55.49 %
>         700 char, eq:      18116   |       8070   |  55.45 %
>         800 char, eq:      20643   |       9124   |  55.80 %
>         900 char, eq:      23179   |      10291   |  55.60 %
>
> [benm at 164-99-120-44 play]$ mono -O=all streq.exe
>                 Test:    Current   |    Andreas   |   Change
>               ptr eq:        115   |        102   |  11.30 %
>           length neq:        572   |        302   |  47.20 %
>  10, neq, first char:        291   |        302   |  -3.78 %
>   10, neq, last char:        533   |        301   |  43.53 %
>           0 char, eq:        223   |        213   |   4.48 %
>           1 char, eq:        259   |        219   |  15.44 %
>           2 char, eq:        326   |        228   |  30.06 %
>           3 char, eq:        338   |        237   |  29.88 %
>           4 char, eq:        382   |        248   |  35.08 %
>           5 char, eq:        396   |        255   |  35.61 %
>           6 char, eq:        440   |        263   |  40.23 %
>           7 char, eq:        445   |        274   |  38.43 %
>           8 char, eq:        514   |        286   |  44.36 %
>           9 char, eq:        514   |        294   |  42.80 %
>          10 char, eq:        587   |        304   |  48.21 %
>          11 char, eq:        580   |        309   |  46.72 %
>          12 char, eq:        631   |        318   |  49.60 %
>          13 char, eq:        641   |        330   |  48.52 %
>          14 char, eq:        699   |        347   |  50.36 %
>          15 char, eq:        695   |        345   |  50.36 %
>          16 char, eq:        763   |        327   |  57.14 %
>          17 char, eq:        751   |        337   |  55.13 %
>          18 char, eq:        808   |        343   |  57.55 %
>          19 char, eq:        808   |        355   |  56.06 %
>          20 char, eq:        862   |        362   |  58.00 %
>          40 char, eq:       1465   |        493   |  66.35 %
>          60 char, eq:       2064   |        627   |  69.62 %
>          80 char, eq:       2665   |        733   |  72.50 %
>         100 char, eq:       3254   |        865   |  73.42 %
>         150 char, eq:       4918   |       1184   |  75.93 %
>         200 char, eq:       6429   |       1504   |  76.61 %
>         250 char, eq:       8095   |       1825   |  77.46 %
>         300 char, eq:       9208   |       2146   |  76.69 %
>         350 char, eq:      10944   |       2468   |  77.45 %
>         400 char, eq:      12357   |       2759   |  77.67 %
>         450 char, eq:      13829   |       3075   |  77.76 %
>         500 char, eq:      15650   |       3399   |  78.28 %
>         600 char, eq:      18451   |       4043   |  78.09 %
>         700 char, eq:      21285   |       4686   |  77.98 %
>         800 char, eq:      24276   |       5291   |  78.20 %
>         900 char, eq:      27261   |       5930   |  78.25 %
>
> Some notes:
>       * Why the regression on `10, neq, first char'? Alot of that goes
>         away with -O=all, but still something to look at.

This seems very strange, could you attach the benchmark. Maybe it's a bug in
the bench ;)
I cannot reproduce that with my benchmark where the results are 3005->2384
(with o) and 2814->2613 (without o)

>       * Ditto with `0 char, eq'

The old code had a shortcut for this case which I removed because it should
be a rather seldom case

There is another removed 'shortcut' (sort of) which is for strings with
exactly one char. These are also slightly slower now.

>       * Why does -O=all slow down the current code?

Good question, but beyond my knowledge.
If I would have to guess I would say the structure of the old code is too
complicated.

>       * MS's jit seems to generate much better code than our jit here.
>         We need to look into this. I can't give numbers here because of
>         the lovely EULA ;-(.
>       * You should not run this benchmark against the 1.0 release. Right
>         after 1.0, I added a optimization to the jit which makes
>         get_OffsetToStringData an intrinsic. This makes the statement
>         fixed (char* a = b) much faster -- and that is the only way to
>         get the data from a string if you are not inside the string
>         class.

I'm only working from within the string class. But if a new prebuilt version
comes I'll use it ;)




More information about the Mono-devel-list mailing list