[squeak-dev] Proper use of SourceFiles and "CurrentReadOnlySourceFiles cacheDuring:"

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Thu Jan 6 23:46:22 UTC 2022

> Now I wonder whether it is really so simple.

Hm ... Not, it seems not, unfortunately. With the described change, my 2nd source file gets a nil fileID from time to time. Apparently, #changeRecordsForMethod:do: has some side weird effects on the sources file that cannot be prevented by resetting the file positions in an ensure block. :(

Von: Thiede, Christoph
Gesendet: Donnerstag, 6. Januar 2022 22:28:51
An: Squeak Dev
Betreff: Proper use of SourceFiles and "CurrentReadOnlySourceFiles cacheDuring:"

Hi all!

While investigating why Squot is so slow in my image, I found out that the following takes ~7 seconds in my image:

package := PackageInfo named: 'Tools'.
[package overriddenMethods] timeToRun.

According to the profiler, 48% of the time are spent in StandardFileStream>>#unregister and 33% in StandardFileStream>>#open:forWrite:.

By rewriting PackageInfo>>#changeRecordsForMethod:do: to use CurrentReadOnlySourceFiles rather than SourceFiles and wrapping the above invocation with "CurrentReadOnlySourceFiles cacheDuring:", I was able to reduce the run time of my script to ~1.5 seconds.

Now I wonder whether it is really so simple. Do I understand the class comment of CurrentReadOnlySourceFiles correctly that it is best practice to *always* use this fancy exception for any regular access to the source files? If yes, why are we having so few senders to CurrentReadOnlySourceFiles class >> #at: and so many senders to SourceFiles? Are we having a huge chance to optimize the image by rewriting all these senders? If you think this a good idea, I will be glad to do so! :-)

And here's another question: Why do we need to close the sources file again and again at all. Whenever you navigate within any browsing tool (a very popular workload for some people here, I think), they are basically opened and closed upon every click, aren't they? Why can't we keep them open all the time? Is this to avoid data loss, or would it decelerate the operating system? Thanks in advance!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220106/38297d6a/attachment.html>

More information about the Squeak-dev mailing list