Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Approaching pws-15



Bart Schaefer wrote:

> On Apr 13,  1:45pm, Peter Stephenson wrote:
> > pws-15 should appear real soon now.  I haven't included the optimisation of
> > ${..#..} and ${..%..} yet, do people think this is slow enough to need the
> > special cases?
> 
> I confess that I'm skeptical of the value of the optimization.  Sven, you
> said you did profiling -- care to share a few before/after numbers?  Just
> how slow was it in the first place, and how much does this improve it?

As I said in 6009, I wasn't too sure about it anymore, too (and didn't 
like the special casing). Especially since (as I forgot to say) this
was done with a interim version of `_path_files' which did a lot more
`${...#...}'.

But maybe we should at least keep the `getmatcharr()' function to
avoid parsing the pattern `$#array' times. Should we?

Anyway, without the patch I got something like:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 41.21      1.57     1.57   102250     0.02     0.02  zhalloc
 18.37      2.27     0.70    96755     0.01     0.01  zfree
  9.97      2.65     0.38   102441     0.00     0.00  malloc
  1.84      2.72     0.07    83548     0.00     0.00  matchonce
  1.57      2.78     0.06   120527     0.00     0.00  charmatch
  1.05      2.82     0.04    66371     0.00     0.02  hcalloc
  1.05      2.86     0.04    63354     0.00     0.02  doesmatch
  1.05      2.90     0.04     3712     0.01     0.05  parsecompsw
  1.05      2.94     0.04      849     0.05     1.87  paramsubst
...
                                 849             stringsubst <cycle 4> [128]
[6]     41.6    0.04    1.55     849         paramsubst <cycle 4> [6]
                0.00    1.49    2358/2358        getmatch [8]
...
                0.17    0.00   11345/102250      dupstrpfx [43]
                0.22    0.00   14414/102250      dupstring [38]
                1.02    0.00   66371/102250      hcalloc [12]
[7]     41.3    1.57    0.00  102250         zhalloc [7]
                0.00    0.00     248/96755       zfree [14]
                0.00    0.00     249/49979       zalloc [41]
                0.00    0.00     248/102441      malloc [29]
...
                0.00    1.49    2358/2358        paramsubst <cycle 4> [6]
[8]     39.2    0.00    1.49    2358         getmatch [8]
                0.00    0.60    2358/2441        parsereg [16]
                0.02    0.51    2196/2196        dolongestmatch [20]
                0.00    0.32    1382/5432        domatch [9]
                0.01    0.04    2358/2358        get_match_ret [73]
...
                0.00    0.51    2196/5432        dolongestmatch [20]
[9]     32.9    0.00    1.25    5432         domatch [9]
                0.11    1.14    5432/5432        doesmatch <cycle 2> [11]
...
[10]    32.9    0.11    1.14    5432+141566  <cycle 2 as a whole> [10]
                0.04    1.10   63354+22642       doesmatch <cycle 2> [11]
                0.07    0.04   83548             matchonce <cycle 2> [49]
...
                0.00    0.06    3720/66371       allocnode [61]
                0.01    0.17   10780/66371       insertlinknode [31]
                0.01    0.22   14471/66371       dupstruct2 <cycle 6> [35]
                0.01    0.23   14773/66371       newlinklist [37]
                0.01    0.31   19826/66371       compalloc [32]
[12]    27.9    0.04    1.02   66371         hcalloc [12]
                1.02    0.00   66371/102250      zhalloc [7]

With the patch this was reduced to:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 44.23      0.92     0.92    68471     0.01     0.01  zhalloc
 10.10      1.13     0.21    28530     0.01     0.01  malloc
  9.13      1.32     0.19    22918     0.01     0.01  zfree
  4.33      1.41     0.09    72353     0.00     0.00  matchonce
  2.88      1.47     0.06     2860     0.02     0.11  dupstruct2
  2.40      1.52     0.05    42661     0.00     0.00  hwaddc
  0.96      1.54     0.02    62448     0.00     0.00  doesmatch
...
                0.03    0.00    2442/68471       get_match_ret [60]
                0.03    0.00    2501/68471       gettokstr <cycle 4> [49]
                0.14    0.00   10414/68471       dupstring [32]
                0.63    0.00   47209/68471       hcalloc [7]
[6]     44.4    0.92    0.00   68471         zhalloc [6]
                0.00    0.00     172/22918       zfree [25]
                0.00    0.00     173/14236       zalloc [37]
                0.00    0.00     172/28530       malloc [22]
...
                0.00    0.05    3720/47209       allocnode [46]
                0.00    0.15   10876/47209       insertlinknode [29]
                0.00    0.20   14471/47209       dupstruct2 <cycle 6> [11]
                0.00    0.20   14773/47209       newlinklist [23]
[7]     31.1    0.01    0.64   47209         hcalloc [7]
                0.63    0.00   47209/68471       zhalloc [6]
...
                                 849             stringsubst <cycle 4> [124]
[21]    10.9    0.01    0.22     849         paramsubst <cycle 4> [21]
                0.00    0.15      60/60          getmatcharr [31]
...
                0.00    0.15      60/60          paramsubst <cycle 4> [21]
[31]     7.2    0.00    0.15      60         getmatcharr [31]
                0.00    0.13    1168/1168        igetmatch [34]
                0.00    0.02      60/60          quickgetmatcharr [77]
...
                0.00    0.13    1168/1168        getmatcharr [31]
[34]     6.1    0.00    0.13    1168         igetmatch [34]
                0.00    0.11    1168/3076        domatch [14]
                0.00    0.02    1168/2442        get_match_ret [60]
...
                0.00    0.02      60/60          getmatcharr [31]
[77]     1.1    0.00    0.02      60         quickgetmatcharr [77]
                0.00    0.02    1266/1286        iquickgetmatch [78]
                0.00    0.00      40/68471       zhalloc [6]
                0.00    0.00      60/80          quickpat [268]
                0.00    0.00      40/1436        arrlen [410]


Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author