Re: TclX loop slow in the default case



On Sep 8, 10:00 pm, miguel <mso...@xxxxxxxxxxxx> wrote:
Alexandre Ferrieux wrote:
Can you retry with larger N (a total of 15000 us is too small to
eliminate various overheads)?
100 times larger should be OK (1.5s).

Alex found a bug that was causing this, now fixed in HEAD.

Evil Son: could you run your tests again please?

n=1,000,000 was taking too long so I'll run these later. Yes there is
a definite improvement - we are within ~10% of naked for. But to get
this result, I introduced cheat5 after studying Donal's king-cheat
more closely. I don't know if (1)-(3) captures the king-cheat
sufficiently, but perhaps I misunderstand them.

Anyway, I implemented cheat4 (the one that I thought captured (1)-(3))
in my test as follows (removing the bookkeeping of scores):

if {$proc eq "cheat4"} {
time {set var {}; cheat2 var 0 $n the-body} $nIter
}

So I simply redirected to cheat2.

#But should it have been this:

proc cheat5 {var from to body} {
set var {}
cheat2 var $from $to $body
}

And *this* performs within 10% of the naked for.

What of Alex's and Miguel's patches? They improve cheat4 by about 2%
and improve cheat5 by about 22% !

Here are the results:
-----------------------------------------------------------------------
[n = 10000, time in us] <---- Just to get the results out quickly
forL tclx naive clever cheat1 cheat2 cheat3 cheat4
cheat5
8.4.19 4225 18008 101106 32436 32165 21078 32508 21698
13388
8.5.3 3972 23169 105209 27897 28256 24472 28258 24856
16745
8.5.4 4107 24542 17427 36370 15730 13848 16268 13700
7260
8.6a2 4638 34986 26260 49080 17552 15182 17547 15104
6133
20080908 4337 33868 29356 50387 17266 15044 17276 15133
6114
20080909 4340 35242 29650 52326 17350 15100 17414 14979
4765

[Compare down only]
forL tclx naive clever cheat1 cheat2 cheat3 cheat4
cheat5
8.4.19 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
1.00
8.5.3 0.94 1.29 1.04 0.86 0.88 1.16 0.87 1.15
1.25
8.5.4 0.97 1.36 0.17 1.12 0.49 0.66 0.50 0.63
0.54
8.6a2 1.10 1.94 0.26 1.51 0.55 0.72 0.54 0.70
0.46
20080908 1.03 1.88 0.29 1.55 0.54 0.71 0.53 0.70
0.46
20080909 1.03 1.96 0.29 1.61 0.54 0.72 0.54 0.69
0.36

[Compare across only]
forL tclx naive clever cheat1 cheat2 cheat3 cheat4
cheat5
8.4.19 1.00 4.26 23.93 7.68 7.61 4.99 7.69 5.14
3.17
8.5.3 1.00 5.83 26.49 7.02 7.11 6.16 7.11 6.26
4.22
8.5.4 1.00 5.98 4.24 8.86 3.83 3.37 3.96 3.34
1.77
8.6a2 1.00 7.54 5.66 10.58 3.78 3.27 3.78 3.26
1.32
20080908 1.00 7.81 6.77 11.62 3.98 3.47 3.98 3.49
1.41
20080909 1.00 8.12 6.83 12.06 4.00 3.48 4.01 3.45
1.10

-----------------------------------------------------------------------

I will be modifying my tests and running them again so the next batch
will have scores that will not be comparable to these ones.

Question: does (1)-(3) capture the optimisation?

A BIG WELL DONE!

Cheers
Evil Son

.



Relevant Pages

  • Re: TclX loop slow in the default case
    ... I introduced cheat5 after studying Donal's king-cheat ...  I don't know if -captures the king-cheat ... I implemented cheat4 -) ... [Compare across only] ...
    (comp.lang.tcl)
  • Re: TclX loop slow in the default case
    ... I introduced cheat5 after studying Donal's king-cheat ... ridiculously small and exposes one-shot overheads) ... Each proc loops 0 --> 10000000 ... [Compare across only] ...
    (comp.lang.tcl)
  • Re: TclX loop slow in the default case
    ... I introduced cheat5 after studying Donal's king-cheat ... [Compare across only] ... Miguel did the decisive fix. ... ridiculously small and exposes one-shot overheads) ...
    (comp.lang.tcl)