Hi Philippe,

On Sat, Jan 1, 2011 at 4:06 AM, Philippe Marschall <[email protected]> wrote:

> On 31.12.2010 03:02, Eliot Miranda wrote:
> >
> >
> >
> >
> > Hi All,
> >
> >      I've released a new version of Cog that has a substantially
> > improved code generator along the lines of Peter Deutsch's HPS
> > (VisualWorks) and various of Ian Piumarta's VMs.  These all use a simple
> > tecnique to identify constant references in bytecode and to support a
> > register-based calling convention.  While this does produce faster code
> > it tends to accelerate low-level code much more than high-level code as
> > you can see by the following benchmarks:
> >
> > SimpleStackBasedCogit: [1 to: 100000000 do: [:i|]] timeToRun 691
> > StackToRegisterMappingCogit: [1 to: 100000000 do: [:i|]] timeToRun 192
> > 192 - 691 / 6.91 -72%
> >
> > SimpleStackBasedCogit: 0 tinyBenchmarks '753495217 bytecodes/sec;
> > 64769127 sends/sec'
> > StackToRegisterMappingCogit: 0 tinyBenchmarks '931756141 bytecodes/sec;
> > 128157989 sends/sec'
> > 931756141 - 753495217 / 7534952.17 -24%
> > 128157989 - 64769127 / 647691.27 -98%
> >
> > SimpleStackBasedCogit: [Compiler recompileAll] timeToRun 47013 (no
> > transcript
> > StackToRegisterMappingCogit: [Compiler recompileAll] timeToRun 43406 (no
> > transcript)
> > 43406 - 47013 / 470.13 -7.67234594686576
> >
> > The status of this code is essentially beta.  The test suite runs the
> > same on the new code generator as on the old, but I think there are
> > still bugs because I get the occasional transient error.  I am therefore
> > very interested in any reproducible errors you can find.
> >
> > The VMs (http://www.mirandabanda.org/files/Cog/VM/VM.r2334/) contain a
> > few other important changes:
> >
> > - a bug fix to bytecode<->native pc mappng that produced incorrect
> > results for methods containing blocks with ^-returns in them.  One
> > symptom is incorrect highlighting of the pc in the debugger, althoguh
> > symptoms could be much serious.
> >
> > - jitting interpreted methods on backward branches.  Currently any
> > interpreted method that performs more than 20 backward branches will be
> > considered for JIT compilation and if it is suitable (default, <= 60
> > literals) will be compiled to native code.
> >
> > - new callback support.  I need to commit some changes to the Alien
> > package to provide access to this but essentially the VM's callback
> > support is now able to be ported to architectures with register-based
> > calling conventions (ARM, PowerPC, SPARC etc).  I'll try and get the
> > Alien code released soon, and to back-port the changes to the standard
> > VM before the end of the holiday.
> >
> > One thing that is still /not/ fixed is the lack of a SoundPlugin on
> > win32.  Apologies.  I'll try and get a fix for this before the end of
> > the holidays too, but time might be too tight.  There are other
> > priorities such as harmonising the standard and Cog VMs for the 4.2
> release.
>
> I gave it a short test with the latest Seaside.
>
> First the good news, I seem to get an average performance improvement of
> about 10%.
>
> However in some very rare cases the temps seem to be mixed up the very
> first time a method is executed and fine afterwards. For example in the
> method below when the div 'bench' is created. The very first time it is
> executed #div is sent to a BlockClosure, the next time it is fine. This
> is reproducible, if I recompile the package or restart the image it
> happens again the first time and is fine afterwards.
>

I'm very interested in this because the way I've implemented the register
based calling convention means that arguments and the return pc get
rearranged at various places and typically activation code takes an
alternate path the first time.  So this seems indicative of a bug I would
expect.

>
> I don't know how I can provide more information but I could upload the
> image somewhere.
>

Please do.  You can provide me with a URL.  But also provide idiot
instructions for reproducing the issue, e.g. a workspace expression or a
carefully detailed set of user interface actions.  Ideally (for me :) )
you'll produce an image that demonstrates the error on startup.  e.g. by
using the pattern

    Smalltalk saveAs.
    MyClass doSomething

So that MyClass doSomething gets performed immediately on startup.

Thanks!

Eliot

>
>
> renderInline: aBlock factor: factor key: key on: html
>        | startTime endTime count backColor anAssociation title
> referenceValue
> spi context document renderer stream runTime |
>        count := 0.
>        runTime := 200.
>        anAssociation := referenceDict
>                at: key
>                ifAbsent: [ 'Undefined' -> 100000 ].
>        title := anAssociation key.
>        referenceValue := anAssociation value.
>        stream := WriteStream on: String new.
>        document := builder documentClass
>                on: stream
>                codec: builder codec.
>        context := WARenderContext new.
>        context document: document.
>        context
>                actionUrl: builder actionUrl;
>                resourceUrl: builder resourceUrl.
>        renderer := builder rendererClass context: context.
>        builder
>                openDocument: document
>                context: context.
>        html div
>                class: 'bench';
>                with:
>                        [ html heading: title.
>                        startTime := Time millisecondClockValue.
>                        endTime := startTime + runTime.
>                        [ Time millisecondClockValue < endTime ] whileTrue:
>                                [ count := count + 1.
>                                renderer
>                                        render: aBlock;
>                                        flush ] ].
>        builder closeDocument: document.
>        spi := (count / referenceValue * (10000 / runTime)) rounded.
>        backColor := spi > 100
>                ifTrue: [ '#5f5' ]
>                ifFalse:
>                        [ spi < 50
>                                ifTrue: [ '#f55' ]
>                                ifFalse: [ '#55f' ] ].
>        duration := duration + spi.
>        html div
>                style: 'float:left;padding:4px';
>                with:
>                        [ html big: spi greaseString , ' SPI'.
>                        html span
>                                class: 'iteration';
>                                with: '(' , count greaseString , '
> iterations)'.
>                        html break.
>                        html div
>                                class: 'rect';
>                                style: 'background:' , backColor , ';width:'
> , (spi * 2)
> greaseString , 'px' ].
>        html div style: 'clear:both'
>
> Cheers
> Philippe
>
>
>

Reply via email to