[squeak-dev] FileStreams Limit

David T. Lewis lewis at mail.msen.com
Thu Feb 17 16:18:51 UTC 2022


On Thu, Feb 17, 2022 at 05:05:43PM +0100, J??rg Belger wrote:
> The least I expect is that I get a debugger in Smalltalk when the limit is reached and not a Squeak that is not reactive and consumes 100% cpu time. But anyway I get the hanging Squeak already with 242 file streams, independent if I set the #maxExternalSemaphores to 8192.
> 
> If I do the same in VisualWorks and open 4000 write streams I have no problems with limits, so I guess it is not an operating system limit, it is a Squeak VM limit. There is no reason why everything needs to be implemented in C code, the goal should be to implement as much as we can in Smalltalk.
> 
> The reason why I opened so much files is that the Squeak file API is very slow for my realtime streaming, so I simply leave the files open.
> Here is an example:
> 
> VisualWorks needs 700ms
> Time millisecondsToRun:
> 	[| filename |
> 	filename := 'test.txt' asFilename.
> 	10000 timesRepeat:
> 		[filename readWriteStream close]]
> 
> Squeak needs 4000ms
> Time millisecondsToRun:
> 	[10000 timesRepeat: [(FileStream fileNamed: 'test,txt???) close]]

On my Linux box it only takes about 100ms.


> 
> If you can tell me a faster way to open/write/close a file it would be nice.
> 
> J??rg
> 

You may want to try profiling it to see where the time is going:

  TimeProfileBrowser onBlock: [10000 timesRepeat: [(FileStream fileNamed: 'test,txt') close]].

Dave




More information about the Squeak-dev mailing list