Ideas for solving SLOW MultiByteFileStream nextPutAll:

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

Ideas for solving SLOW MultiByteFileStream nextPutAll:

Nicolas Cellier
Well, this is latin1-centric, but could speed-up a majority of us,
since most code is written in English.

The idea is to use Andreas fast conversions ByteString>>#squeakToUtf8 ...
However creating an intermediary Stream then an intermediary String is
not necessary...

So we'll have to replace this with dispatching techniques.
Moreover, the technique can be generalized to other encodings.
More more over, the lineEndConventions can be handled by the very same trick.

To achieve this, we install a latin1Map and latin1Encodings as class
instance variables in TextConverter to generalize Andreas'
squeakToUtf8 trick.

Then we copy these in instance variables. This is to enable
lineEndConventions mapping.

Then we care to #installLineEndConventionInConverter in
MultiByteFileStream to initialize TextConverter variables.

Then we use following dispatching:

MultiByteFileStream nextPutAll:
-> TextConverter nextPutAll:

And use a hack for ByteString in TextConverter nextPutAll:
(dispatching on String would be overkill by now).

To measure how it can enhance things, I put a hack
in Debugger class>>#openOn:context:label:contents:fullView:
                Preferences logDebuggerStackToFile
                                ifTrue: [MessageTally spyOn: [Smalltalk
                                                logError: title
                                                inContext: context
                                                to: 'SqueakDebug.log']]

Then did a 0/0
FasterLatin1Conversion reduce tallies from  - 11452 tallies, 11586
msec. to  - 3625 tallies, 3718 msec.
Still a little bit long for a Debugger to open, but already better.

Nicolas

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

FasterLatin1Conversion-Part1.1.cs (2K) Download Attachment
FasterLatin1Conversion-Part2.1.cs (3K) Download Attachment
FasterLatin1Conversion-Part3.1.cs (4K) Download Attachment
FasterLatin1Conversion-Part4.1.cs (730 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Ideas for solving SLOW MultiByteFileStream nextPutAll:

Stéphane Ducasse
Thanks nicolas
I would like to have much more time to devote to pharo. But I'm(sick  
right now) and have a lot of mess
around (home....)
I will let mike give you some comments. My knowledge about UTf-8 is  
too limited and the way squeak handles it
is even weaker (with leading char and other beasts).

Stef

On May 10, 2009, at 2:28 AM, Nicolas Cellier wrote:

> Well, this is latin1-centric, but could speed-up a majority of us,
> since most code is written in English.
>
> The idea is to use Andreas fast conversions  
> ByteString>>#squeakToUtf8 ...
> However creating an intermediary Stream then an intermediary String is
> not necessary...
>
> So we'll have to replace this with dispatching techniques.
> Moreover, the technique can be generalized to other encodings.
> More more over, the lineEndConventions can be handled by the very  
> same trick.
>
> To achieve this, we install a latin1Map and latin1Encodings as class
> instance variables in TextConverter to generalize Andreas'
> squeakToUtf8 trick.
>
> Then we copy these in instance variables. This is to enable
> lineEndConventions mapping.
>
> Then we care to #installLineEndConventionInConverter in
> MultiByteFileStream to initialize TextConverter variables.
>
> Then we use following dispatching:
>
> MultiByteFileStream nextPutAll:
> -> TextConverter nextPutAll:
>
> And use a hack for ByteString in TextConverter nextPutAll:
> (dispatching on String would be overkill by now).
>
> To measure how it can enhance things, I put a hack
> in Debugger class>>#openOn:context:label:contents:fullView:
> Preferences logDebuggerStackToFile
> ifTrue: [MessageTally spyOn: [Smalltalk
> logError: title
> inContext: context
> to: 'SqueakDebug.log']]
>
> Then did a 0/0
> FasterLatin1Conversion reduce tallies from  - 11452 tallies, 11586
> msec. to  - 3625 tallies, 3718 msec.
> Still a little bit long for a Debugger to open, but already better.
>
> Nicolas
> <FasterLatin1Conversion-Part1.1.cs><FasterLatin1Conversion-
> Part2.1.cs><FasterLatin1Conversion-
> Part3.1.cs><FasterLatin1Conversion-
> Part4.1.cs>_______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project