<div dir="ltr">Hi,<div><br></div><div>I tried to analyse the problem and I think I found the cause and a potential solution.<br><div><br></div><div>I have just tried Ben's script in the 32 bits latest VM (Squeak.cog.spur) and at the bottom of the mail are the results in [1]. I modified the script to print the error codes. The ratio are a bit different from 64 bits, but the same pattern is present. The primitive fails once every 40-60 allocations in 32 bits instead of every 10-15 allocations in 64 bits, with every ~15 failures allocations working better for a short while. The primitive always fails for 'insufficient object memory'. </div><div><br></div><div>The allocation strategy is different for objects which size cannot be encoded in 16 bits (in our case, array larger than 65535 fields). Large objects are directly allocated in old space. The failures in shallowCopy happen in this case. I believe the case where many large objects are allocated in a row is not really optimised because it supposed to be uncommon. If it's common in someone's usecase, I am pretty sure we can do something about it.</div><div><br></div><div>Because the memory is in bytes and array fields are twice bigger in 64 bits, I would expect the failures to be twice more frequent in 64 bits than 32 bits. They seem to be 4 times more frequent, but different persons did the 64 bits measurements on different machines, so it could be that other side-effects require to be considered.</div><div><br></div><div>One solution I see is the following (Pharo version, in Squeak use directly <font face="monospace, monospace">vmParameterAt</font>:) :</div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">coef := 2.</font></div><div><div><font face="monospace, monospace">Smalltalk vm parameterAt: 25 put: (Smalltalk vm parameterAt: 25) * coef.</font></div><div><font face="monospace, monospace">Smalltalk vm parameterAt: 24 put: (Smalltalk vm parameterAt: 24) * coef.</font></div></div><div><br></div><div>Basically, I change the old space heuristics to allocate bigger segments and not to shrink too aggressively.  </div><div><br></div><div>With a coef of 2, I see the primitive failing once every 58-87 times instead of once every 40-60 allocations.</div><div>With a coef of 10, I see the primitive failing once every 350-700 allocations. The results for coef 10 are in [2] at the bottom of the mail.</div><div><br></div><div>Obviously with these settings the image is using a bit more RAM, but I guess in the use-case of Ciprian where images are 6.8Gb large it does not really matter to waste a dozen extra Mb.</div><div><br></div><div>Coef 2 may lead to a waste of ~15Mb</div><div>Coef 10 may lead to a waste of ~150Mb</div><div><br></div><div>I don't think there is a generic magic solution for 64 bits. We could consider having twice bigger segments by default in 64 bits ? I don't know if it makes sense.</div><div><div><br></div><div>I have on my TODO list to build a GC object for Pharo (normally Squeak-compatible) to provide convenient APIs and documentation on how to adapt the GC policy in Spur for both growing and large heaps. Hopefully I will do that around June.</div><div><br></div><div>[1]</div><div>65631<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>65631<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>#'insufficient object memory'</div><div>65689<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>58<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>65747<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>58<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>...</div><div>65979<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>58<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>66616<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>637<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>66673<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>57<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>66730<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>57<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>...</div><div>67243<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>57<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>67698<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>455<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>67754<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>56<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>67810<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>56<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>...</div><div>68538<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>56<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>68817<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>279<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>68872<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>55<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div><div>...</div><div>99860<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>38<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>#'insufficient object memory'</div></div><div><br></div><div><div>[2]</div><div>66720<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>66720<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>#'insufficient object memory'</div><div>68303<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>1583<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>#'insufficient object memory'</div><div>69850<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>1547<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>#'insufficient object memory'</div><div>70231<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>381<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>70610<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>379<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>71363<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>753<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>72107<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>744<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>72844<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>737<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>73574<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>730<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>74296<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>722<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>74654<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>358<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>75011<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>357<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>75719<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>708<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>76071<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>352<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>...</div><div>98404<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>816<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>98945<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>541<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div><div>99214<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>269<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>#'insufficient object memory'</div></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 7, 2017 at 7:58 PM, Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
What's the error code when the primitive fails?<span class="HOEnZb"><font color="#888888"><br>
<br>
Levente<br>
</font></span></blockquote></div><br></div>