Squeak file stream performance

Marcel Weiher marcel at system.de
Sat Aug 14 16:26:38 UTC 1999


> From: "Michel Tilman" <mtilman at acm.org>
>
>     | stream |
>
>     stream := FileStream newFileNamed: 'Bad.txt'.
>     17476266 timesRepeat:
>          [ stream nextPutAll: 'BAD' ].
>     stream close
>
> to its Vw5i counterpart:
>
>     | stream |
>
>     stream := 'Bad.txt' asFilename writeStream.
>     17476266 timesRepeat:
>          [ stream nextPutAll: 'BAD' ].
>     stream close
>
> Time for the Squeak version is 12 min 18 seconds, for VW5i 23  
seconds, a

The same code takes 2 minutes 30 seconds on my machine a G3/233  
running Squeak via MacOS-X-Server.

> rather large (32 times) performance difference, although the Squeak 
> #nextPutAll: method builds directly on a primitive. Flushing every  
character
> write in VW hardly slowed it down. The PC is a Pentium III 450  
with 256 MB
> RAM. Does anyone have any ideas about this difference?

Yes.  Your code exercises the interpreter very heavily because it  
only writes 3 bytes on each pass through the loop.  The Squeak  
interpreter imposes much greater interpretation overhead than the VW  
JIT-compiler.  Even just doubling the number of bytes written per  
iteration will significantly improve performance.  On my machine,  
writing the same data in 36 byte chunks brings the time down to  
approximately 12 seconds.

As a general rule, you want to leverage primitive operations as much  
as possible in any interpreter system.

Marcel





More information about the Squeak-dev mailing list