[squeak-dev] The Inbox: Collections-nice.807.mcz

Levente Uzonyi leves at caesar.elte.hu
Sat Sep 15 23:58:08 UTC 2018


Hi Eliot,

Here is a very simple test case:

{
 	[ 1 to: 500000000 do: [ :i | i = 1 ifTrue: [ true ] ifFalse: [ false ] ] ] timeToRun.
 	[ 1 to: 500000000 do: [ :i | i = 1 ] ] timeToRun.
}

On my machine it gives #(992 1436).

Levente

On Sun, 16 Sep 2018, Eliot Miranda wrote:

> Hi Levente,
> On Fri, Sep 14, 2018 at 12:35 AM Levente Uzonyi <leves at caesar.elte.hu> wrote:
>       On Thu, 13 Sep 2018, commits at source.squeak.org wrote:
>
>       > Nicolas Cellier uploaded a new version of Collections to project The Inbox:
>       > http://source.squeak.org/inbox/Collections-nice.807.mcz
>       >
>       > ==================== Summary ====================
>       >
>       > Name: Collections-nice.807
>       > Author: nice
>       > Time: 13 September 2018, 9:29:57.057799 pm
>       > UUID: f4686e6e-1820-4c3f-841d-c1904914c147
>       > Ancestors: Collections-topa.806
>       >
>       > Let isSeparator be consistent with Character separators after introduction of nbsp.
>       >
>       > The performance cost should be marginal.
>       >
>       > Note: some (CharacterSet cleanUp: false) might be necessary in postscript, unless this is included in the release process...
>       >
>       > =============== Diff against Collections-topa.806 ===============
>       >
>       > Item was changed:
>       >  ----- Method: Character>>isSeparator (in category 'testing') -----
>       >  isSeparator
>       >       "Answer whether the receiver is one of the separator characters--space,
>       > +     cr, tab, line feed, or form feed and nbsp."
>       > -     cr, tab, line feed, or form feed."
>       >
>       >       | integerValue |
>       > +     (integerValue := self asInteger) > 32 ifTrue: [ ^integerValue = 160 "non breaking space" ].
>
>       Unfortunately the current JIT will not optimize that construct the same
>       way as the ones used in the current implementation, so it'd still be
>       ~1-1.5x slower to use this compared to the "compare with constant and do
>       a quick return" formula. If we really want to push this change, I'd rather
>       try something like this:
>
>               (integerValue := self asInteger) > 32 ifTrue: [
>                       integerValue = 160 ifTrue: [ ^true ].
>                       ^false ].
> 
> 
> I'd rather you provide a test case and encourager me to fix the JIT to produce faster code.  It seems absurd to have to write such crappy code, and maybe the JIT will be easy to fix.
>  
>
>       Levente
>
>       > -     (integerValue := self asInteger) > 32 ifTrue: [ ^false ].
>       >       integerValue
>       >               caseOf: {
>       >                       [ 32 "space" ] -> [ ^true ].
>       >                       [ 9 "tab" ] -> [ ^true ].
>       >                       [ 13 "cr"] -> [ ^true ].
>       >                       [ 10 "line feed" ] -> [ ^true ].
>       >                       [ 12 "form feed"] -> [ ^true ] }
>       >               otherwise: [ ^false  ]!
> 
> 
> 
> --
> _,,,^..^,,,_
> best, Eliot
> 
>


More information about the Squeak-dev mailing list