<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 7, 2022 at 8:35 AM Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu">leves@caesar.elte.hu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi Christoph,<br>
<br>
On Thu, 6 Jan 2022, Thiede, Christoph wrote:<br>
<br>
> <br>
> Hi all!<br>
> <br>
> <br>
> While investigating why Squot is so slow in my image, I found out that the following takes ~7 seconds in my image:<br>
> <br>
> <br>
> package := PackageInfo named: 'Tools'.<br>
> [package overriddenMethods] timeToRun.<br>
<br>
That's very likely due to windows+anti-virus. 52ms here.<br>
<br>
> <br>
> According to the profiler, 48% of the time are spent in StandardFileStream>>#unregister and 33% in StandardFileStream>>#open:forWrite:.<br>
<br>
Are those the leaves or just random nodes in the tree?<br>
<br>
> <br>
> <br>
> 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<br>
> time of my script to ~1.5 seconds.<br>
<br>
That's expected. :)<br>
<br>
> <br>
> <br>
> 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?<br>
<br>
It is so simple, as long as the code is only reading from those files and <br>
the code doesn't try to close them.<br>
<br>
> 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<br>
> good idea, I will be glad to do so! :-)<br>
<br>
There are so few senders, because<br>
- CurrentReadOnlySourceFiles is a "new" thing<br>
- CurrentReadOnlySourceFiles should actually be a ProcessLocalVariable, <br>
but when I created CurrentReadOnlySourceFiles, Squeak didn't have PLVs.<br>
- not everyone agrees on that concurrent source file reads outside the UI <br>
thread should be supported<br>
<br>
> <br>
> <br>
> 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<br>
<br>
If you don't close the files, you'll run out of file descriptors and your <br>
image will stop working.<br>
Even if you don't close the files explicitly, the GC will do it, but that <br>
will be slower.<br>
It's also better to close them explicitly because it's not free (for the <br>
OS) to have the same file opened 500 times.<br>
<br>
> 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!<br>
<br>
If CurrentReadOnlySourceFiles were a PLV, there would practically be no <br>
need to close the files.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">If the source file model supported something like substituteReadOnlySourceFilesDuring: and substituteWritableSourceFilesDuring:, the former being used in the debugger, the l;atter when writing to the changes and sources files, then we wouldn't need CurrentReadOnlySourceFiles at all.  The whole design is backwards.  There is *no need* to create a new source file for every read; that's insane.  There is only a need to avoid the debugger tripping over itself.  There have never been any thread-safety guarantees with the sources file and the UI ensures that compilation and browsing are essentially single-threaded.  I wish we would engineer this properly and not keep using the ugly CurrentReadOnlySourceFiles hack.  [and no criticism is implied of you Levente; the thing works ok-ish, but things could be so much better]</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Levente<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>