<div dir="ltr">Hi Bert,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 2, 2014 at 11:23 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div style="word-wrap:break-word">On 02.09.2014, at 17:03, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt; wrote:<br>
<div><br><blockquote type="cite"><div dir="ltr">Hi Bert,<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 1, 2014 at 7:13 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On 01.09.2014, at 15:56, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt; wrote:<br>


<br>
&gt;&gt; Another thought is that given the abundance of memory these days, we might cache both sources and changes in main memory (which would also speed up full-text searches).<br>
&gt;<br>
&gt; Pharo is planning to eliminate them altogether which is more coherent than caching them.<br>
<br>
</div>That&#39;s another discussion, but it might be a step towards that.<br>
<div><br>
&gt;  But IMO the solution is easy, maintain a *single* read-only copy of the sources and changes files in SourceFilesArray (or whatever the class is called; I&#39;m on my phone) and read source through them instead of reopen ing the damn things all the time.<br>


<br>
</div>Except that Squeak files do not maintain an independent file position pointer, so reading from different positions in the same file is not thread-safe. That&#39;s why the file is opened again.<br></blockquote><div>

<br></div><div>Can you explain more.  I don&#39;t understand.</div></div></div></div></blockquote><div><br></div><div>I think we&#39;re in violent agreement ;) This was a comment on the image-side file handling, not about the VM. (Although we might need better file prims. Tim appears to have ideas)</div>
<div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>  As I see it every file instance has its own FILE structure so I don&#39;t understand how this can be so.  Files are derived from FilePlugin&#39;s primitiveFileOpen function.  That is implemented in terms of fileOpenNamesizewritesecure, which allocates a ByteArray to hold state (so no two Smalltalk files share state) and then uses sqFileOpen to open the underlying file and fill in the state.  The C library implementation of sqFileOpen in platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c uses fopen et al, again creating unique state. </div>
</div></div></div></blockquote><div><br></div><div>Precisely. Every Squeak file-open also opens an OS file via fopen(). The number of files a process can open is limited. That is why we run out of file handles unless the files gets closed properly.</div>
<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> So I don&#39;t see how having a writable Smalltalk file and a separate read-only Smalltalk file on the sources and changes can result in other than two separate independent file pointers.</div>
</div></div></div></blockquote><div><br></div><div>What I was getting at is that it would be much better to actually open the file only once (or twice, once for writing and once for read-only) and then maintain a file pointer in the image independently of the OS&#39;s file position. That is how we could share a single read-only file for many readers. </div>
</div></div></blockquote><div><br></div><div>Right, now we are in agreement.  That&#39;s what I like.  1 read-only copy, one writeable copy for the changes file, and presumably a single read-only file for the sources file.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>The problem is that the OS file also has a file position, and the file positions we maintain in the image would easily get out of sync with that.</div>
</div></div></blockquote><div><br></div><div>Potentially, but don&#39;t do that.  If the image wants to update the file position it must also use primSetPosition:to: to keep the OS file pointer up-to-date.  There&#39;s a thread-safety issue, but that&#39;s to be kept orthogonal for now (the current situation also has such issues).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">

<div>There *is* an issue with the structure of file access in the debugger.  If one were to step through execution of accessing source from e.g. the read-only sources file then the very act of fetching sources for the methods being displayed would confuse the state in the file one was observing through the debugger.  But that&#39;s hardly a new situation (one can get into a similar situation with the current setup), and the debugger could ease the situation by wrapping source access with something that reset the file&#39;s buffer etc.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><br>
&gt; Then the file&#39;s own buffers will provide done caching.  Annoying that I write this code in 2008 for newspeak but we still rely on the mad &quot;run the GC to finalize files when open fails&quot; approach.<br>
<br>
</div>Well, you writing this for newspeak does not immediately benefit Squeak. But if you point us to the code maybe someone can port it to Squeak?<br></blockquote><div><br></div><div>I already did a year or two ago and it got shot down on the debugger grounds I reiterated above.</div>
</div></div></div></blockquote><br></div><div>Well, maybe it&#39;s time to revisit, then.</div></div></blockquote><div><br></div><div>Will do.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><span style="font-family:Helvetica;font-size:12px">- Bert -</span><br></div></div></blockquote></div><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>