Hi Marian,<div><br></div><div>    I intend to eliminate compact classes this year.  See </div><div><a href="goog_1053221753"><br></a></div><div><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2009-March/134461.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2009-March/134461.html</a></div>
<div><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2009-March/134465.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2009-March/134465.html</a><br><br></div><div>HTH</div><div>Eliot</div><div>
<br><div class="gmail_quote">On Thu, May 6, 2010 at 2:24 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br>Hi folks. I was just trying to understand this optimization of the Compact Classes. If I understood correctly, most objects needs a second word there they have 30 bits of OOP of their class and 2 for the header type. <br>

<br>



There are classes that have a LOT of instances. For those cases we have compact classes where their instances have a number using those 5 bits in the first word of the header, and thus, they don&#39;t need a second header. Then, less memory is used.<br>





<br>So...I understood ok ?<br><br>Now, if that is the situation. I have evaluated Smalltalk compactClassesArray  and I see that in the array there are a lot of nils. 16 classes in Squeak and 15 in Pharo. The rest of the 31, are just nil. <br>





<br>Now I wonder if it is worth to do anything with that :<br><br>a) Use 4 bits instead of 5 and free one more bit in the OH<br>b) remove completely CompactClasses as Adrian said<br>c) Let 5 bits but then add more classes (up to 31) so that we can get benefits of that. Do you know if there are side effects of becomingCompact a class ?<br>





<br>If I evaluate SpaceTally new printSpaceAnalysis  I get something like this:<br><br>Class                           code space # instances  inst space percent<br>ByteString                            2217       71317       3621735    19.3<br>




CompiledMethod                       21064       56057       3517772    18.7<br>Bitmap                                3893        2256       3424604    18.2<br>Array                                 2478       71108       2198420    11.7<br>




ByteSymbol                             959       37896        962465     5.1<br>ByteArray                             2778         317        778297     4.1<br>MethodDictionary                      1819        5964        449252     2.4<br>




MCVersionInfo                         1313       10369        414760     2.2<br>DateAndTime                           6974       13793        331032     1.8<br>WeakArray                              827         286        326900     1.7<br>




Association                            749       26784        321408     1.7<br>UUID                                  1528       10370        248880     1.3<br>Float                                11442       16450        197400     1.1<br>




ClassOrganizer                        1398        5964        190848     1.0<br>ODatedEntry                            263        7049        169176     0.9<br>Time                                  5530       10369        165904     0.9<br>




Duration                              3025       10290        164640     0.9<br>Date                                  3167       10289        164624     0.9<br>LargePositiveInteger                  2515       14340        118169     0.6<br>




Metaclass                             4250        2876        115040     0.6<br>Point                                 6404        8476        101712     0.5<br>GlyphForm                              307        2030         73080     0.4<br>




FreeTypeCacheEntry                     536        2238         71616     0.4<br>SpaceTallyItem                         651        2509         60216     0.3<br>OrderedCollection                     5351        2831         56620     0.3<br>




FreeTypeFileInfo                       797         321         30816     0.2<br>FreeTypeFontFamilyMember              1274         537         25776     0.1<br>Color                                21202        1255         25100     0.1<br>




TraitComposition                      2651        2013         24156     0.1<br>Set                                   3510        1358         21728     0.1<br>Dictionary                            5742        1344         21504     0.1<br>




RemoteString                          1533        1236         19776     0.1<br>SparseLargeTable                      2376           2         18708     0.1<br>WordArray                             1821          30         18608     0.1<br>




SoundBuffer                           3299           3         18508     0.1<br>Pragma                                1558         862         17240     0.1<br>Preference                            1534         379         16676     0.1<br>




EventHandler                          3216         125         14500     0.1<br>MorphExtension                        3249         277         14404     0.1<br>Character                             6428         939         11268     0.1<br>




SortedCollection                      1496         462         11088     0.1<br>AdditionalMethodState                 2576         859         10304     0.1<br>ISOLanguageDefinition                18114         402          9648     0.1<br>




TimeStamp                              861         392          9408     0.1<br><br><br>So...for this quick evaluation, maybe we can become compact also the following classes for example:<br><br>Smalltalk compactClassesArray<br>



<br>#( ByteSymbol ByteArray MethodDictionary &quot;Association&quot; &quot;WeakArray&quot; &quot;Metaclass&quot; DateAndTime UUID Time Duration Date &quot;MethodDictionary&quot; ClassOrganizer Metaclass Pragma OrderedCollection RemoteString WordArray Color Character ) <br>



do: [:each | (Smalltalk at: each) becomeCompact]<br><br>Do this make sense ? How could I measure this?  I took a Pharo image and compare the memory used by the VM running all test before and after those new compact classes. From the &quot;Activity monitor&quot; I noticed between 3 and 5 MB less used with these new compact classes. <br>


<br>Thanks in advance<br><br>Mariano<br><br><br><div class="gmail_quote">
On Tue, May 4, 2010 at 2:12 PM, Adrian Lienhard <span dir="ltr">&lt;<a href="mailto:adi@netstyle.ch" target="_blank">adi@netstyle.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">





<br>
Hi Mariano,<br>
<br>
I see two solutions<br>
- make the identityHash (even) smaller<br>
- remove compact classes<br>
<br>
The former would probably not be hard to implement (just change some bit masks and then rehash all sets). I&#39;ve brought up the idea about the latter some time ago on this mailing list. The idea is to remove compact classes to get a larger identityHash (trading memory against speed). After the removal, only two header types are left and hence you gain a spare bit. I think this shouldn&#39;t be too much work either, but I haven&#39;t come around to implementing it (yet).<br>






<br>
Good luck ;)<br>
<font color="#888888">Adrian<br>
</font><div><div></div><div><br>
On May 4, 2010, at 13:13 , Mariano Martinez Peck wrote:<br>
<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Now...the question is, is there another free bit in the object header ? I<br>
&gt;&gt;&gt; need another one :(<br>
&gt;&gt;<br>
&gt;&gt; Based on the comment at the bottom of Interpreter&gt;&gt;internalIsImmutable:<br>
&gt;&gt; I suspect that somebody else has their eye on that last available bit<br>
&gt;&gt; also ;-)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; Yes, I know :(   But for the moment I don&#39;t care to &quot;integrate&quot; my stuff.  I<br>
&gt; just want to play and experiment. And even for that, I need 2 bits :(<br>
&gt; Of course, if I once make something good to integrate, I will have double<br>
&gt; problem :(<br>
&gt;<br>
&gt; So...no solution ?<br>
<br>
</div></div></blockquote></div><br>
<br></blockquote></div><br></div>