<br><br><div class="gmail_quote">On Sun, Mar 1, 2009 at 1:01 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@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;">
2009/3/1 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt;<br>
&gt;<br>
&gt; On Sun, Mar 1, 2009 at 12:23 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; 2009/3/1 Andreas Raab &lt;<a href="mailto:andreas.raab@gmx.de">andreas.raab@gmx.de</a>&gt;:<br>
&gt;&gt; &gt; Igor Stasenko wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Changing the object formats alone does not gives any benefits. What is<br>
&gt;&gt; &gt;&gt; the point in having new format when you keep using old semantic model<br>
&gt;&gt; &gt;&gt; as before?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Speed. That is the only point of the exercise to begin with.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; This is like swapping instance variables order in your class.. Apart<br>
&gt;&gt; &gt;&gt; from a better aestetical view it gives you nothing :)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; If swapping ivars in a class would give me a 3x in performance I&#39;d be<br>
&gt;&gt; &gt; doing<br>
&gt;&gt; &gt; this all day long...<br>
&gt;&gt; &gt;<br>
&gt;&gt; but we both know that this is too good to be true.  :)<br>
&gt;&gt; unless you change the way how things working, you can&#39;t achieve<br>
&gt;&gt; significant performance boost. And often this means rewriting<br>
&gt;&gt; interfaces, which inevitably leads to changing a lot of code on<br>
&gt;&gt; language side etc.<br>
&gt;<br>
&gt; Uh, no.  Here is the inline cache check in Cog, which is as complicated as<br>
&gt; it is because of compact classes:<br>
&gt; 00009588: movl %edx, %eax : 89 D0<br>
&gt; 0000958a: andl $0x00000001, %eax : 83 E0 01<br>
&gt; 0000958d: jnz .+0x00000011 (0x000095a0=singleRelease@40) : 75 11<br>
&gt; 0000958f: movl %ds:(%edx), %eax : 8B 42 00<br>
&gt; 00009592: shrl $0x0a, %eax : C1 E8 0A<br>
&gt; 00009595: andl $0x0000007c, %eax : 83 E0 7C<br>
&gt; 00009598: jnz .+0x00000006 (0x000095a0=singleRelease@40) : 75 06<br>
&gt; 0000959a: movl %ds:0xfffffffc(%edx), %eax : 8B 42 FC<br>
&gt; 0000959d: andl $0xfffffffc, %eax : 83 E0 FC<br>
&gt; 000095a0: cmpl %ecx, %eax : 39 C8<br>
&gt; 000095a2: jnz .+0xffffffda (0x0000957e=LSICMissCall) : 75 DA<br>
&gt; In VisualWorks the code looks like<br>
&gt;     movl %ebx, %eax<br>
&gt;     andl $3, %eax<br>
&gt;     jnz LCompare<br>
&gt;     movl (%ebx), %eax<br>
&gt; LCompare:<br>
&gt;     cmpl %eax, %edx<br>
&gt;     jnz +0xffffff??=LSICMissCall<br>
&gt; That&#39;s 9 or 11 instructions (compact vs non-compact) vs 6 instructions in<br>
&gt; the common case, but vitally, for non-compact classes 2 memory reads vs one.<br>
&gt; So indeed object representation can make a major difference in run-time<br>
&gt; performance.  Consider how much quicker object allocation is in VW, which<br>
&gt; does not have to check if the receiving class is compact or not, compared to<br>
&gt; Squeak. Consider how much quicker string access is in VW, which has<br>
&gt; immediate characters, than Squeak with the character table and the inability<br>
&gt; to do == comparisons on Unicode characters. etc. etc.<br>
<br>
</div></div>Sometimes I having troubles with expressing my thoughts clearly.. sorry.</blockquote><div><br></div><div>No need to apologise.  Everyone (me especially) can take a few mail messages to converge on the right meaning from time to time.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I din&#39;t mean that changing object format does not improves the speed.<br>
I meant that such changes alone is very hard to adopt without ANY<br>
changes on language side.<br>
See<br>
Behavior&gt;&gt;becomeCompact<br>
becomeCompactSimplyAt: index<br>
becomeUncompact<br>
<br>
see also<br>
#compactClassesArray<br>
<br>
and i suspect this list is only a top of the iceberg (for instance,<br>
you may need to change SpaceTally to report things properly).</blockquote><div><br></div><div>You&#39;re absolutely right.  The major image-level change I will require is for Behavior to implement identityHash with a primitive that is different form that in Object.  Doing this allows me to implement a hidden class table in the VM where a class&#39;s identity hash is the index into the class table.  An instance of a class has the class&#39;s class table index (the class&#39;s id hash) stored in its header, not a direct pointer to the class.  So every object has a more compact class reference, say 16, 20 or 24 bits.  Also, class references in in-line and method caches are class indices, not direct class references, which means less work on GC.  But to ensure a class can be entered in the table by the VM at an unused index Behaviour&gt;&gt;identityHash must be a special primitive that the VM implements as searching the table for an unused index.</div>
<div><br></div><div>But the imager-level code for compact classes can still exist; its just that the VM will ignore it :)</div><div><br></div><div>Of course you&#39;re right about SpaceTally.  Perhaps the VM should provide some primitives that allow SpaceTally to be parameterised.  of course it&#39;s not until one tries to use such a parameterised SpaceTally on more than one object representation that one knows the design works across a range of object representations.  And its not as if one will be trying new object representations every week (although I don&#39;t know :) ).  But it might be worth the effort.  But probably simpler is having the kernel of SpaceTaly&#39;s computatioons be in the microkernel image, and writing some suitable tests to be run in a derivative image.</div>
<div><br></div><div>But my experience with 64-bit VW is that there are very few changes.  We had the Behaviour&gt;&gt;identityHash primtiive, the primitive that answered the size of the hash field, and that&#39;s about it.  Note that the image already computes the size of SmallInteger by doing subtractions until overflow at start-up.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Now, defending you point, that really, it would be much easier to deal<br>
with such things in a micro-image (consider the amount of code and<br>
tests which you need to perform when producing new update).<br>
<br>
This makes you, as a VM developer be responsible from good integration<br>
of VM with language side.<br>
Then rest images, which is based on it will have to use things<br>
strictly in manner, as it put in kernel.<br>
It is important to draw a line between kernel and rest of the code in<br>
image, which depends on it.</blockquote><div><br></div><div>Right.  Agreed.  And experience shows (16-bit =&gt; 32-bit, Squeak &amp; VW 64-bit) that the new constraints introduced by the microkernel will be very few and unobtrusive.</div>
<div><br></div><div>Best</div><div>Eliot</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<div class="Ih2E3d"><br>
&gt;&gt;<br>
&gt;&gt; &gt; Cheers,<br>
&gt;&gt; &gt;  - Andreas<br>
&gt;&gt; &gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; Igor Stasenko AKA sig.<br>
&gt;<br>
&gt; Best<br>
&gt; Eliot<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div>--<br>
<div><div></div><div class="Wj3C7c">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>