Small text composition bench

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Small text composition bench

Nicolas Cellier
Here is a simple bench:

(StringHolder new contents:  (Compiler evaluate: (FileStream fileNamed: 'text.st') contentsOfEntireFile )) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorphPlus] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(NewParagraph new)
        compose: tm text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].

Before our changes: 162 ms
After our changes: 95 ms
And my Pharo 3.0 (#30417) (not up to date) :  364 ms

The main gain is avoiding
- the stopConditions copy
- and the TextStopConditions indirection
- and of course the Multi* when not necessary (Pharo does not)

Here is the test for Pharo variant:

| text |
text := Compiler evaluate: (FileSystem workingDirectory parent parent parent / 'text.st' ) readStream contentsOfEntireFile .
(StringHolder new contents:  text) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorph] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(Paragraph new)
        compose: text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].





text.st (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

Nicolas Cellier
And here are the tallies attached


2013/10/10 Nicolas Cellier <[hidden email]>
Here is a simple bench:

(StringHolder new contents:  (Compiler evaluate: (FileStream fileNamed: 'text.st') contentsOfEntireFile )) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorphPlus] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(NewParagraph new)
        compose: tm text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].

Before our changes: 162 ms
After our changes: 95 ms
And my Pharo 3.0 (#30417) (not up to date) :  364 ms

The main gain is avoiding
- the stopConditions copy
- and the TextStopConditions indirection
- and of course the Multi* when not necessary (Pharo does not)

Here is the test for Pharo variant:

| text |
text := Compiler evaluate: (FileSystem workingDirectory parent parent parent / 'text.st' ) readStream contentsOfEntireFile .
(StringHolder new contents:  text) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorph] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(Paragraph new)
        compose: text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].






new_squeak_13254_tallies.txt (4K) Download Attachment
old_squeak_13004_tallies.txt (3K) Download Attachment
Pharo_30417_tallies.txt (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

Nicolas Cellier
And in Squeak 3.7 with interpreter VM 4.10.10, 197ms
Squeak 2.8 with interpreter VM 4.2.5beta1U, 174ms

| text |
text := Compiler evaluate: (FileStream fileNamed: 'text.st') contentsOfEntireFile.
MessageTally spyOn: [[100 timesRepeat: [(NewParagraph new)
        compose: text
        style: TextStyle default copy
        from: 1
        in: ( 0@0 corner: 569@9999999)]] timeToRun ].


2013/10/10 Nicolas Cellier <[hidden email]>
And here are the tallies attached


2013/10/10 Nicolas Cellier <[hidden email]>
Here is a simple bench:

(StringHolder new contents:  (Compiler evaluate: (FileStream fileNamed: 'text.st') contentsOfEntireFile )) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorphPlus] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(NewParagraph new)
        compose: tm text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].

Before our changes: 162 ms
After our changes: 95 ms
And my Pharo 3.0 (#30417) (not up to date) :  364 ms

The main gain is avoiding
- the stopConditions copy
- and the TextStopConditions indirection
- and of course the Multi* when not necessary (Pharo does not)

Here is the test for Pharo variant:

| text |
text := Compiler evaluate: (FileSystem workingDirectory parent parent parent / 'text.st' ) readStream contentsOfEntireFile .
(StringHolder new contents:  text) openLabel:  'Working With Squeak 2' .
((SystemWindow allSubInstances detect: [:e | e label = 'Working With Squeak 2']) findDeepSubmorphThat: [:m | m class = PluggableTextMorph] ifAbsent: [] ) textMorph
ifNotNil: [:tm | MessageTally spyOn: [
    [100 timesRepeat: [(Paragraph new)
        compose: text
        style: tm textStyle copy
        from: 1
        in: tm container]] timeToRun]].







squeak_37_5989_tallies.txt (3K) Download Attachment
Squeak_28_tallies_1000run.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

timrowledge
It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful Latin Phrases:- Canis meus id comedit = My dog ate it.



Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

Eliot Miranda-2



On Thu, Oct 10, 2013 at 5:02 PM, tim Rowledge <[hidden email]> wrote:
It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.

+1
 

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful Latin Phrases:- Canis meus id comedit = My dog ate it.






--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

David T. Lewis
In reply to this post by timrowledge
On Thu, Oct 10, 2013 at 05:02:56PM -0700, tim Rowledge wrote:
> It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.
>

Really impressive!

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

Nicolas Cellier
It's COG that's impressive in this case (well, as long as Spur is not ready).
Indeed, the latest squeak still spends 713ms with a 4.10.10 interpreter VM, so primitive 103 makes a difference...
On the Pi, it still makes sense to try and restore primitive 103 - for the simple case of StrikeFont and ByteString...


2013/10/11 David T. Lewis <[hidden email]>
On Thu, Oct 10, 2013 at 05:02:56PM -0700, tim Rowledge wrote:
> It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.
>

Really impressive!

Dave





Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

Nicolas Cellier
I also tried composition in Cuis4.2 which is interesting because it uses the primitive 103, but is around 111ms for other reasons

| text |
text := Compiler evaluate: (FileStream fileNamed: 'text_cuis.st') contentsOfEntireFile.
MessageTally spyOn: [[100 timesRepeat: [(TextComposer new)
                composeLinesFrom: 1
                to: text size
                delta: 0
                into: OrderedCollection new
                priorLines: OrderedCollection new
                atY: 0
                text: text
                extentForComposing: ( 569@9999999)]] timeToRun ].


2013/10/11 Nicolas Cellier <[hidden email]>
It's COG that's impressive in this case (well, as long as Spur is not ready).
Indeed, the latest squeak still spends 713ms with a 4.10.10 interpreter VM, so primitive 103 makes a difference...
On the Pi, it still makes sense to try and restore primitive 103 - for the simple case of StrikeFont and ByteString...


2013/10/11 David T. Lewis <[hidden email]>

On Thu, Oct 10, 2013 at 05:02:56PM -0700, tim Rowledge wrote:
> It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.
>

Really impressive!

Dave







Cuis42_TextComposition_tallies.txt (5K) Download Attachment
text_cuis.st (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

timrowledge

On 12-10-2013, at 4:34 AM, Nicolas Cellier <[hidden email]> wrote:

> On the Pi, it still makes sense to try and restore primitive 103 - for the simple case of StrikeFont and ByteString...

I agree - though we'd have to use a different primitive name so as not to clash with supporting older images on the plain interpreter.

I think I'd be inclined to add it to the bitbltplugin on the basis that it is a sibling to the primitiveDisplayString code. That might even make it sensible to go back to the Old Ways and have a boolean flag to the prim for display/no-display and call the blt directly.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Fractured Idiom:- FELIX NAVIDAD - Our cat has a boat



Reply | Threaded
Open this post in threaded view
|

Re: Small text composition bench

J. Vuletich (mail lists)
In reply to this post by Nicolas Cellier

Thanks Nicolas. This thread has been enlightening! I did some changes recently, mostly inspired in yours, that improve perfomance and simplify code.

You can download a fully updated Cuis from https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev . It should be a bit faster.

Thanks,

Juan Vuletich

Quoting Nicolas Cellier <[hidden email]>:

I also tried composition in Cuis4.2 which is interesting because it uses the primitive 103, but is around 111ms for other reasons

| text |
text := Compiler evaluate: (FileStream fileNamed: 'text_cuis.st') contentsOfEntireFile.
MessageTally spyOn: [[100 timesRepeat: [(TextComposer new)
                composeLinesFrom: 1
                to: text size
                delta: 0
                into: OrderedCollection new
                priorLines: OrderedCollection new
                atY: 0
                text: text
                extentForComposing: ( 569@9999999)]] timeToRun ].


2013/10/11 Nicolas Cellier <[hidden email]>
It's COG that's impressive in this case (well, as long as Spur is not ready).
Indeed, the latest squeak still spends 713ms with a 4.10.10 interpreter VM, so primitive 103 makes a difference...
On the Pi, it still makes sense to try and restore primitive 103 - for the simple case of StrikeFont and ByteString...


2013/10/11 David T. Lewis <[hidden email]>

On Thu, Oct 10, 2013 at 05:02:56PM -0700, tim Rowledge wrote:
> It looks like we can feel good about the last week or so's work. Thanks for joining in and doing such good work.
>

Really impressive!

Dave




Cheers,
Juan Vuletich