<div dir="ltr">Hi Jakob,<div><br></div><div>   (ignore the earlier reply)<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 16, 2017 at 3:09 PM, Jakob Reschke <span dir="ltr"><<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>></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">Hi,<div dir="auto"><br></div><div dir="auto">I almost expected this feedback regarding allInstances ;-) If the change is still only in the Inbox, no harm should have been done, otherwise somebody else should revert it in trunk.</div></div></blockquote><span class="gmail-im" style="font-size:12.800000190734863px"><br></span><div style="color:rgb(0,0,0);font-size:12.800000190734863px">OK, good :-)</div><div> </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"><div dir="auto">An alternative would be to enumerate only the Environments registered in that class pool variable. It requires everyone to use the correct "constructor" though, when the Environment is set up.<br></div></div></blockquote><div><br></div><span class="gmail-im" style="font-size:12.800000190734863px"><br></span><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px">Surely an Environment is installed in some other environment, much like a class being installed in its superclass, and hence being present in its superclass's subclasses array.  Hence one can enumerate all classes starting from the thisClass's of the subclasses of Class class (see Class class>>rootsOfTheWorld).</span></div><div><br></div><div>BTW, <span style="color:rgb(0,0,0);font-size:12.800000190734863px">rootsOfTheWorld is currently defined as</span></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px">Class class>></span>rootsOfTheWorld</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>"return a collection of classes which have a nil superclass"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>^(Smalltalk globals select: [:each | each isBehavior and: [each superclass isNil]]) asOrderedCollection</div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px">Far faster and more elegant is</span></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px">Class class>></span>rootsOfTheWorld</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>"return a collection of classes which have a nil superclass"</div><div><span style="white-space:pre">        </span>Class subclasses</div><div><span style="white-space:pre">      </span><span style="white-space:pre">     </span>select: [:c| c theNonMetaClass superclass isNil]</div><div><span style="white-space:pre">      </span><span style="white-space:pre">     </span>thenCollect: [:mc| mc theNonMetaClass]</div><div><br></div><div>So if an Environment is always in relation to the root environment, and environments refer to those that they contain, all installed environments can be enumerated from the root, touching a small fraction of the entire object graph, unlike allInstancesDo: which visits every object in the heap.</div><div><br></div><div>For example, in a 250 Mb image</div><div><div><br></div><div><div><br></div><div>{[ProtoObject withAllSubclasses] timeToRun. [| insts | (insts := Metaclass allInstances), (insts collect: [:ea| ea theNonMetaClass])] timeToRun } #(5 15)</div></div></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"><div dir="auto">For the sake of learning some more: I have plenty of garbage environments in my image (due to test cases creating them and references I will have to track down at another time), but the allInstancesDo does not remarkably slow down the navigation features for me. Which cases do you have in mind when you say that it does not scale?</div></div></blockquote><div><br></div><div>Multi-gigabyte images on 64-bits.  We could conceivably have images in the 10's of gigabytes soon and allInstances would crawl.  As the above illustrates, enumerating about 250Mb of objects costs about 10ms, for 40ms/Gb (and that's on quite a fast machine; the ARM is significantly slower).</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"><div dir="auto">Best,<br></div><div dir="auto">Jakob</div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">Am 16.05.2017 23:21 schrieb "Eliot Miranda" <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>>:<br type="attribution"></span><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>
<div dir="ltr">Hi Jakob,
<div><br>
</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span class="gmail-">On Tue, May 16, 2017 at 10:09 AM, <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span> wrote:<br>
</span><div><div class="gmail-h5"><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">
A new version of System was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/System-jr.948.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox<wbr>/System-jr.948.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: System-jr.948<br>
Author: jr<br>
Time: 5 May 2017, 12:08:58.857884 am<br>
UUID: 4a19b143-6a23-b549-ab15-0d548d<wbr>a859f4<br>
Ancestors: System-ul.947<br>
<br>
incorporate behaviors from other environments in allBehaviorsDo:<br>
<br>
This enables senders/implementors and method searches across environments.<br>
<br>
=============== Diff against System-ul.947 ===============<br>
<br>
Item was changed:<br>
  ----- Method: SystemNavigation>>allBehaviors<wbr>Do: (in category 'query') -----<br>
  allBehaviorsDo: aBlock<br>
        "Evaluate the argument, aBlock, for each kind of Behavior in the system<br>
        (that is, Object and its subclasses and Traits).<br>
        ar 7/15/1999: The code below will not enumerate any obsolete or anonymous<br>
        behaviors for which the following should be executed:<br>
<br>
                Smalltalk allObjectsDo:[:obj| obj isBehavior ifTrue:[aBlock value: obj]].<br>
<br>
        but what follows is way faster than enumerating all objects."<br>
<br>
+       Environment allInstancesDo: [:environment |<br>
+               environment allClassesAndTraitsDo: [ :class |<br>
+                       aBlock value: class.<br>
+                       class isTrait ifFalse: [ "class of a Trait is Trait, there are no MetaTraits"<br>
+                               aBlock value: class class ] ] ]!<br>
-       self environment allClassesAndTraitsDo: [ :class |<br>
-               aBlock value: class.<br>
-               class isTrait ifFalse: [ "class of a Trait is Trait, there are no MetaTraits"<br>
-                       aBlock value: class class ] ]!<br>
</blockquote>
<div><br>
</div>
</div></div><span class="gmail-"><div>Forgive me for being blunt but Environment allInstancesDo: is absurd and unacceptable.  Environments *must* build some kind of graph that can be enumerated without recourse to a hammer like allInstancesDo:.  This simply doesn't scale.  And it suffers the
 problem of enumerating environments that are no longer in use but have yet to be garbage collected.  Please roll back this change and take a better approach.</div>
<div><br>
</div>
</span></div>
<div class="gmail-m_-2511317019720172929m_123561147477942795m_-6762673259426350850gmail_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>
</div>
</div>

</blockquote></div></div>
<br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div 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></div></div>