<div dir="ltr"><div><div>I'm having problems with the statistics...<br></div><div>I tried Andres' version of allSubclasses and to my surprise it is slower than my version in the Stack VM, that is the one I use for Live Typing, but it is slightly faster with the JIT VM (only a 0.01%)</div><div>I don't see the 20% improvement that you mentioned Andres, what are the number you got?</div><div>These are the numbers I get doing this, three times:</div><div><br></div><div>Smalltalk garbageCollect.<br>Time millisecondsToRun: [ 1000 timesRepeat: [ Behavior allSubclasses ]].  <br></div><div><br></div><div>JIT VM: </div><div>Breath first version:   169  170  171 </div><div>Depth first version: 181 179 180 </div></div><div><br></div><div>Stack VM:</div><div><div><div>Breath first version:  776  780  788</div><div>Depth first version: 749  749  751 </div></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 24, 2019 at 11:22 AM Juan Vuletich via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Uh, I hadn't seen you had already attached code, and only answered to <br>
the comments. Apologies for that!<br>
<br>
This new version is much faster. Thanks! I integrated it at GitHub, with <br>
a short comment about the iterative vs. recursive choice.<br>
<br>
Cheers,<br>
<br>
-- <br>
Juan Vuletich<br>
<a href="http://www.cuis-smalltalk.org" rel="noreferrer" target="_blank">www.cuis-smalltalk.org</a><br>
<a href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev" rel="noreferrer" target="_blank">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a><br>
<a href="https://github.com/jvuletich" rel="noreferrer" target="_blank">https://github.com/jvuletich</a><br>
<a href="https://www.linkedin.com/in/juan-vuletich-75611b3" rel="noreferrer" target="_blank">https://www.linkedin.com/in/juan-vuletich-75611b3</a><br>
@JuanVuletich<br>
<br>
<br>
<br>
On 8/23/2019 7:34 PM, Andres Valloud via Cuis-dev wrote:<br>
> See attached for your reference.<br>
><br>
> On 8/22/19 05:36, Juan Vuletich wrote:<br>
>> On 8/21/2019 4:29 PM, Andres Valloud via Cuis-dev wrote:<br>
>>> What do you see as "ugly"?<br>
>><br>
>> It is way more complicated than needed to solve the problem. The <br>
>> problem is trivial, this code is not. And there is no reason for <br>
>> this: class hierarchy depths shouldn't be so deep to be a challenge <br>
>> for the call stack.<br>
>><br>
>> Hernán's code is only as complex as the problem, without accidental <br>
>> complexity (in the Fred Brooks sense). It is a clear explanation of <br>
>> the problem and the solution.<br>
>><br>
>> To me, code aesthetics is not only about code being clear, and a good <br>
>> explanation of the problem and the solution. It is also about being <br>
>> the best fit for the problem (including human readers here: the <br>
>> system is the curricula). Sometimes, performance requirements or <br>
>> space constraints require additional complexity. Then, I see that <br>
>> extra complexity as pretty. This is of course subjective, like any <br>
>> aesthetic judgment.<br>
>><br>
>>> One detail I don't see mentioned here: the old code filled the <br>
>>> ordered collection breadth first (before the set conversion), and so <br>
>>> it has limited execution stack depth.  The current code fills the <br>
>>> collection depth first, so its execution stack depth is as deep as <br>
>>> the hierarchy tree.<br>
>>><br>
>>> Maybe there was a reason why the users of allSubclasses were better <br>
>>> off with breadth first, before someone put in asSet.  Or perhaps <br>
>>> asSet was always there, I don't see why that was beneficial.<br>
>>><br>
>>> In any case, I tried both the recursive and (properly implemented) <br>
>>> iterative methods: breadth first is >20% faster.<br>
>>><br>
>>> On 8/21/19 05:44, Juan Vuletich via Cuis-dev wrote:<br>
>>>> Wow, thanks. The old code was slow and ugly!<br>
>>>><br>
>>>> Integrating it.<br>
>>>><br>
>>>> Cheers,<br>
>>>><br>
>>>> -- <br>
>>>> Juan Vuletich<br>
>>>> <a href="http://www.cuis-smalltalk.org" rel="noreferrer" target="_blank">www.cuis-smalltalk.org</a><br>
>>>> <a href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev" rel="noreferrer" target="_blank">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a><br>
>>>> <a href="https://github.com/jvuletich" rel="noreferrer" target="_blank">https://github.com/jvuletich</a><br>
>>>> <a href="https://www.linkedin.com/in/juan-vuletich-75611b3" rel="noreferrer" target="_blank">https://www.linkedin.com/in/juan-vuletich-75611b3</a><br>
>>>> @JuanVuletich<br>
>>>><br>
>>>><br>
>>>> On 8/21/2019 9:26 AM, Hernan Wilkinson via Cuis-dev wrote:<br>
>>>>> Hi,<br>
>>>>>  attached is a cs that changes the implementation of <br>
>>>>> #allSubclasses and #withAllSubclasses and generates performance <br>
>>>>> improvement drastically.<br>
>>>>>  Just as a quick example, with the current implementation:<br>
>>>>>  Time millisecondsToRun: [ 100 timesRepeat: [Behavior <br>
>>>>> withAllSubclasses ]] 1140 .<br>
>>>>>  With the proposed change:<br>
>>>>>  Time millisecondsToRun: [ 100 timesRepeat: [Behavior <br>
>>>>> withAllSubclasses2 ]]  . 73<br>
>>>>><br>
>>>>>  In the type checker of LiveTyping, checking Behavior goes from <br>
>>>>> 9.5 seconds to 5 seconds only with that change.<br>
>>>>>  One difference between the current and proposed version, is that <br>
>>>>> the current returns a Set while the proposed version returns an <br>
>>>>> OrderedCollection.<br>
>>>>>  I looked carefully if that could break something and it does not. <br>
>>>>> I've been using the image with this new implementation and <br>
>>>>> everything works fine.<br>
>>>>><br>
>>>>>  Juan, please take a look at it and integrate it if you think it <br>
>>>>> is useful.<br>
>>>>>  Hernan.<br>
>>>>><br>
>>>>> -- <br>
>>>>> *Hernán Wilkinson<br>
>>>>> Agile Software Development, Teaching & Coaching*<br>
>>>>> *Phone: +54-011*-4893-2057<br>
>>>>> *Twitter: @HernanWilkinson*<br>
>>>>> *site: <a href="http://www.10Pines.com" rel="noreferrer" target="_blank">http://www.10Pines.com</a> <<a href="http://www.10pines.com/" rel="noreferrer" target="_blank">http://www.10pines.com/</a>>*<br>
>>>>> Address: Alem 896, Floor 6, Buenos Aires, Argentina<br>
>>>><br>
>><br>
>><br>
<br>
<br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal"><span style="font-weight:bold">Hernán Wilkinson</span><br>Agile Software Development, Teaching & Coaching</span></font></span></span></span></strong></span></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">Phone: +54-011</span></font></span></span></span></strong></span><font face="tahoma, sans-serif" size="2">-4893-2057</font></div><div><strong style="font-family:tahoma,sans-serif;font-size:xx-small"><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Twitter: @HernanWilkinson</span></font></span></span></strong></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">site: <a href="http://www.10pines.com/" style="color:rgb(17,65,112)" target="_blank">http://www.10Pines.com</a></span></font></span></span></span></strong></span></div><div><font face="tahoma, sans-serif"><span style="border-collapse:collapse">Address: Alem 896</span></font>, Floor 6, Buenos Aires, Argentina</div></div></div></div></div></div></div></div></div></div></div></div>