<div dir="ltr">Hi all,<br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 22, 2016 at 12:26 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><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"><div dir="auto"><div>Hi Henrik,<br><br></div><div>    cc&#39;ing squeak-dev cuz this is relevant to both communities (if and until Pharo takes the unwise decision to double the size of the image by keeping sources in the image). </div><span class=""><div><br>On May 22, 2016, at 5:01 AM, Henrik Nergaard &lt;<a href="mailto:henrik.nergaard@uia.no" target="_blank">henrik.nergaard@uia.no</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>






<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">There is a method in SourceFileArray #localProcessReadStreamAtFileIndex:atPosition:ifPresent:ifAbsent: which uses a ProccessLocalVariable called
 ProccessAndSessionLocalSourcesFileArray (see #localProcessReadOnlyCopy). Changing the last line in #readStreamAt:ifPresent:ifAbsent: to use this local process one makes the time to run this snippet:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">[ 1 systemNavigation browseMethodsWithSourceString: &#39;Morph&#39; matchCase: false ] timeProfile<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">From ~ 10 seconds to ~ 3 seconds (Windows).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">However I cannot see that the file handles created by this processLocalVariable to ever be closed, so I suspect those are leaked? In that case there
 might be the need to implement some “clean up” mechanism for ProccessLocalVariables before they are changed/nilled when a process changes.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Another approach could be to not use a ProccessLocalVariabe at all, but extend the SourceFilesArray class to also hold one read only handle for each
 of its files, and use these in readStreamAtFileIndex:::… . I guess that it is also necessary then to have semaphore protecting the two last lines such that setting the position in the stream and reading from it cannot be changed by other threads.</span></p></div></div></blockquote><div><br></div></span>I like this approach, but it has a fatal flaw.  If one is debugging file access, then as the debugger causes the source of methods to be fetched as the debugger displays them, so the file pointer in the read-only file the access of which one is trying to debug will change under one&#39;s feet, and the results will be completely wrong.<div><br></div><div>An approach which uses a special copy for the debugger doesn&#39;t work; one can&#39;t debug access to that file for the same reason.</div><div><br></div><div>An approach that /should/ work is for the debugger to install its own copy around file-access.  This should be recursive.  So around every file access in the debugger there would need to be something like</div><div><br></div><div>       SourceFiles substituteFreshReadOnlyCopiesDuring: [...file access...]</div><div><br></div><div>which would remember the current read-only files, evaluate the block using ensure: and have the ensure: block reinstall the previous file.</div><div><br></div><div>Does this make sense?</div><span class=""><div><br></div></span></div></blockquote><div><br></div><div>Interesting discussion. We could give a new try on the &quot;local process read-only copy&quot;.</div><div>It was me who started with it last year in a Pharo sprint, but disabled it due to some errors... and didn&#39;t spend more time on it afterwards. </div><div><br></div><div>it was reported here: <a href="https://pharo.fogbugz.com/f/cases/15782">https://pharo.fogbugz.com/f/cases/15782</a></div><div>the reason to disable it: <a href="https://pharo.fogbugz.com/f/cases/15781/">https://pharo.fogbugz.com/f/cases/15781/</a></div><div><br></div><div>none of them is very clear as documentation of the problem. </div><div><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"><div dir="auto"><span class=""><div><blockquote type="cite"><div><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">readStreamAtFileIndex: index atPosition: position ifPresent: presentBlock ifAbsent: absentBlock<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               | stream  result|<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               stream := self readOnlyFileAt: index.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               stream ifNil: [ ^ absentBlock value ].        &quot;sources file not available&quot;          
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               position &gt; stream size ifTrue: [ ^ absentBlock value ].<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               readSema critical: [<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">                              stream position: position.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">                              result := presentBlock value: stream
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               ].<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">               ^ result<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Best regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Henrik<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif"> Pharo-dev [<a href="mailto:pharo-dev-bounces@lists.pharo.org" target="_blank">mailto:pharo-dev-bounces@lists.pharo.org</a>]
<b>On Behalf Of </b>Nicolai Hess<br>
<b>Sent:</b> Thursday, May 19, 2016 9:31 AM<br>
<b>To:</b> Pharo Development List &lt;<a href="mailto:pharo-dev@lists.pharo.org" target="_blank">pharo-dev@lists.pharo.org</a>&gt;<br>
<b>Subject:</b> Re: [Pharo-dev] From a mooc user: method source with it&#39; take so long in Pharo 5<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Squeak caches the opened readonly file(handle). It does not have to reopen the file on every call for reading (readonly).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">2016-05-18 19:12 GMT+02:00 stepharo &lt;<a href="mailto:stepharo@free.fr" target="_blank">stepharo@free.fr</a>&gt;:<u></u><u></u></p>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<p class="MsoNormal" style="margin-bottom:12pt">I am wondering why does the search &#39;method source with it&#39; take so long in Pharo 5? On my PC, When I select the text &#39;menu&#39; and search for all &#39;method source with it&#39;, in Squeak 5 it takes 3 seconds. In Pharo
 5 it takes 21 seconds.<br>
<br>
<u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>


</div></blockquote></div></span></div><br><br>
<br></blockquote></div><br></div></div>