The Trunk: Collections-dtl.268.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Re: 64 bit images (was Re: The Trunk: Collections-dtl.268.mcz)

David T. Lewis
On Mon, Jan 04, 2010 at 06:49:53PM +0200, Igor Stasenko wrote:
> why its not using
> SmalltalkImage current vmParameterAt: 40
> all the time?
>
> Why keeping this excessive information in ivar/classvar and inventing
> workarounds how to update it
> carefully because of SystemTracer mangling?

Normally that would be the right thing to do, but in the case of
#initialPC the performance impact of the primitive call has a significant
impact. Eliot was quite keen to make sure we did not add that overhead
in the #initialPC call, hence the class variable to save the value.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Re: 64 bit images (was Re: The Trunk: Collections-dtl.268.mcz)

jannik laval
In reply to this post by David T. Lewis
Hi,

I understand your comments,
So:
- i will put word size a class var,
- this class var will be modify only by systemTracer

Now I have a question:
Why using Smalltalk wordSize whereas the vm parameter is getting by SmalltalkImage current ?

Cheers,
Jannik

On Jan 4, 2010, at 17:39 , David T. Lewis wrote:

> On Mon, Jan 04, 2010 at 05:15:28PM +0100, Andreas Raab wrote:
>> Hi Jannik -
>>
>> A couple of comments. First, If wordSize is a constant, put it into a
>> class var. That's the best practice pattern for dealing with constants
>> and I see no reason why one would opt to use an ivar for a value that
>> never changes. See for example the EndianCache in SmalltalkImage and
>> other use of constants throughout the system.
>>
>> As for caching, if I understand your description correctly, then system
>> tracer is storing the correct value for the traced image. When the image
>> starts, your cache code invalidates the known to be correct value which
>> is later lazily filled in with the same value again. So what observable
>> effect does your cache invalidation have?
>>
>> #startUp isn't the first method sent, not by a very long shot - in
>> particular when you mess with the execution machinery you have to be
>> aware that a method like #initialPC might be called before you ever get
>> to the point where you invalidate that cache (I'm not sure if this can
>> happen in this concrete case). In any case you should trace through the
>> startup sequence to find out just how much other code is executed before
>> getting there.
>
> John and/or Bert previously pointed out that there is no need to ever
> set the cached value from the image, so this would be done from a system
> tracer only (and yes this should have a comment).
>
>> My recommendations would be to make WordSize a class variable, leave the
>> lazy initialization in (it might be helpful during install etc) but add
>> a nice comment explaining that only system tracer ever modifies that
>> value when a 32/64 bit image is written. And leave out the pointless
>> cache invalidation :-)
>
> I think that the change set on Mantis 7430 does what you describe. This
> puts the class variable in SystemDictionary in order to retain the current
> "Smalltalk wordSize" idiom, and uses the original Dan Ingalls #initialPC
> implementation from the "dist3" 64-bit image.
>
> It's a small change, so I'll copy it here:
>
> 'From Squeak3.10.2 of 16 December 2009 [latest update: #8496] on 18 December 2009 at 6:08:11 pm'!
> "Change Set: Smalltalk-wordSize-dtl-M7430
> Date: 18 December 2009
> Author: David T. Lewis
>
> Cache Smalltalk wordSize in class var in SystemDictionary..
>
> Update CompiledMethod>>initialPC to use #wordSize. This is the method as implemented in the original 64-bit image (author di)."!
>
> IdentityDictionary subclass: #SystemDictionary
> instanceVariableNames: 'cachedClassNames'
> classVariableNames: 'LastImageName LastQuitLogPosition LowSpaceProcess LowSpaceSemaphore MemoryHogs ShutDownList SpecialSelectors StartUpList StartupStamp SystemChanges WordSize'
> poolDictionaries: ''
> category: 'System-Support'!
>
> !CompiledMethod methodsFor: 'accessing' stamp: 'di 6/29/2004 12:28'!
> initialPC
> "Answer the program counter for the receiver's first bytecode."
>
> ^ (self numLiterals + 1) * Smalltalk wordSize + 1
> ! !
>
>
> !SystemDictionary methodsFor: 'sources, change log' stamp: 'dtl 12/18/2009 00:32'!
> wordSize
> "Answer the size (in bytes) of an object pointer."
> "Smalltalk wordSize"
>
> ^ WordSize ifNil: [WordSize := [SmalltalkImage current vmParameterAt: 40] on: Error do: [4]]! !
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Re: 64 bit images (was Re: The Trunk: Collections-dtl.268.mcz)

David T. Lewis
On Mon, Jan 04, 2010 at 07:09:01PM +0100, Laval Jannik wrote:
> Hi,
>
> I understand your comments,
> So:
> - i will put word size a class var,
> - this class var will be modify only by systemTracer
>
> Now I have a question:
> Why using Smalltalk wordSize whereas the vm parameter is getting by SmalltalkImage current ?

Hi Jannik,

Different people may answer this question in different ways, because it
is a matter of style and personal opinion. But it may help to know that
earlier versions of Squeak had the vm parameter query in SystemDictionary
("Smalltalk") rather than in SmalltalkImage. This was moved as part of
a larger effort to reorganize SystemDictionary, which is a rather large
class that has accumulated many functions over the years.

As matter of function, it makes no difference either way. The part that
is subject to opinion is whether it makes more sense for a person to
say "Smalltalk wordSize" to refer to the size of a word in the object
memory, or whether "SmalltalkImage current wordSize" is more meaningful.

FWIW, my own opinion is that neither one is right, but "Smalltalk wordSize"
is easier to remember. But no matter what approach is taken, you will be able
to find someone who does not agree, so you should form your own opinion ;-)

HTH,

Dave
 

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] Re: 64 bit images (was Re: The Trunk: Collections-dtl.268.mcz)

jannik laval
Thank you Dave,

Jannik

On Jan 4, 2010, at 21:16 , David T. Lewis wrote:

> On Mon, Jan 04, 2010 at 07:09:01PM +0100, Laval Jannik wrote:
>> Hi,
>>
>> I understand your comments,
>> So:
>> - i will put word size a class var,
>> - this class var will be modify only by systemTracer
>>
>> Now I have a question:
>> Why using Smalltalk wordSize whereas the vm parameter is getting by SmalltalkImage current ?
>
> Hi Jannik,
>
> Different people may answer this question in different ways, because it
> is a matter of style and personal opinion. But it may help to know that
> earlier versions of Squeak had the vm parameter query in SystemDictionary
> ("Smalltalk") rather than in SmalltalkImage. This was moved as part of
> a larger effort to reorganize SystemDictionary, which is a rather large
> class that has accumulated many functions over the years.
>
> As matter of function, it makes no difference either way. The part that
> is subject to opinion is whether it makes more sense for a person to
> say "Smalltalk wordSize" to refer to the size of a word in the object
> memory, or whether "SmalltalkImage current wordSize" is more meaningful.
>
> FWIW, my own opinion is that neither one is right, but "Smalltalk wordSize"
> is easier to remember. But no matter what approach is taken, you will be able
> to find someone who does not agree, so you should form your own opinion ;-)
>
> HTH,
>
> Dave
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

12