Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1 participants
- 144619 messages
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Henrik Sperre Johansen
On 21.09.2010 20:28, Mariano Martinez Peck wrote:
>
>
> :) Thanks Henry. Now SpaceTally new spaceForInstancesOf:
> SparseLargeTable withInstanceCount: 2 ->> 18748
>
> So....I guess I should commit the fix for SpaceTally >>
> spaceForInstancesOf: aClass withInstanceCount: instCount
>
> shouldn't I ?
>
>
> In addition, I modified SpaceTally >> printSpaceAnalysis: threshold
> on: aStream
>
> from this:
>
> printSpaceAnalysis: threshold on: aStream
> "SpaceTally new printSpaceAnalysis: 1 on:(FileStream
> forceNewFileNamed: 'STspace.text')"
>
> "sd-This method should be rewrote to be more coherent within the
> rest of the class
> ie using preAllocate and spaceForInstanceOf:"
>
> "If threshold > 0, then only those classes with more than that number
> of instances will be shown, and they will be sorted by total
> instance space.
> If threshold = 0, then all classes will appear, sorted by name."
>
> | totalCodeSpace totalInstCount totalInstSpace n totalPercent |
> Smalltalk garbageCollect.
> totalCodeSpace := totalInstCount := totalInstSpace := n := 0.
> results := OrderedCollection new: Smalltalk classNames size.
> 'Taking statistics...'
> displayProgressAt: Sensor cursorPoint
> from: 0 to: Smalltalk classNames size
> during: [:bar |
> (Smalltalk globals allClasses) do:
> [:cl | | codeSpace instCount instSpace eltSize | codeSpace
> := cl spaceUsed.
> bar value: (n := n+1).
> Smalltalk garbageCollectMost.
> instCount := cl instanceCount.
> instSpace := (cl indexIfCompact > 0 ifTrue: [4] ifFalse:
> [8])*instCount. "Object headers"
> cl isVariable
> ifTrue: [eltSize := cl isBytes ifTrue: [1] ifFalse: [4].
> cl allInstancesDo: [:x | instSpace :=
> instSpace + (x basicSize*eltSize)]]
> ifFalse: [instSpace := instSpace + (cl instSize*instCount*4)].
> results add: (SpaceTallyItem analyzedClassName: cl name
> codeSize: codeSpace instanceCount: instCount spaceForInstances:
> instSpace).
> totalCodeSpace := totalCodeSpace + codeSpace.
> totalInstCount := totalInstCount + instCount.
> totalInstSpace := totalInstSpace + instSpace]].
> totalPercent := 0.0.
>
> "aStream timeStamp."
> aStream
> nextPutAll: ('Class' padded: #right to: 30 with: $ );
> nextPutAll: ('code space' padded: #left to: 12 with: $ );
> nextPutAll: ('# instances' padded: #left to: 12 with: $ );
> nextPutAll: ('inst space' padded: #left to: 12 with: $ );
> nextPutAll: ('percent' padded: #left to: 8 with: $ ); cr.
>
> threshold > 0 ifTrue: [
> "If inst count threshold > 0, then sort by space"
> results := (results select: [:s | s instanceCount >= threshold
> or: [s spaceForInstances > (totalInstSpace // 500)]])
> asSortedCollection: [:s :s2 | s spaceForInstances > s2
> spaceForInstances]].
>
> results do: [:s | | percent |
> aStream
> nextPutAll: (s analyzedClassName padded: #right to: 30
> with: $ );
> nextPutAll: (s codeSize printString padded: #left to: 12
> with: $ );
> nextPutAll: (s instanceCount printString padded: #left to:
> 12 with: $ );
> nextPutAll: (s spaceForInstances printString padded: #left
> to: 14 with: $ ).
> percent := s spaceForInstances*100.0/totalInstSpace roundTo: 0.1.
> totalPercent := totalPercent + percent.
> percent >= 0.1 ifTrue: [
> aStream nextPutAll: (percent printString padded: #left to:
> 8 with: $ )].
> aStream cr].
>
> aStream
> cr; nextPutAll: ('Total' padded: #right to: 30 with: $ );
> nextPutAll: (totalCodeSpace printString padded: #left to: 12
> with: $ );
> nextPutAll: (totalInstCount printString padded: #left to: 12
> with: $ );
> nextPutAll: (totalInstSpace printString padded: #left to: 14
> with: $ );
> nextPutAll: ((totalPercent roundTo: 0.1) printString padded:
> #left to: 8 with: $ ).
>
>
>
> To this:
>
>
>
> printSpaceAnalysis: threshold on: aStream
> "SpaceTally new printSpaceAnalysis: 1 on:(FileStream
> forceNewFileNamed: 'STspace.text')"
>
> "sd-This method should be rewrote to be more coherent within the
> rest of the class
> ie using preAllocate and spaceForInstanceOf:"
>
> "If threshold > 0, then only those classes with more than that number
> of instances will be shown, and they will be sorted by total
> instance space.
> If threshold = 0, then all classes will appear, sorted by name."
>
> | totalCodeSpace totalInstCount totalInstSpace n totalPercent |
> Smalltalk garbageCollect.
> totalCodeSpace := totalInstCount := totalInstSpace := n := 0.
> results := OrderedCollection new: Smalltalk classNames size.
> 'Taking statistics...'
> displayProgressAt: Sensor cursorPoint
> from: 0 to: Smalltalk classNames size
> during: [:bar |
> (Smalltalk globals allClasses) do:
> [:cl | | codeSpace instCount instSpace eltSize | codeSpace
> := cl spaceUsed.
> bar value: (n := n+1).
> Smalltalk garbageCollectMost.
> instCount := cl instanceCount.
> instSpace := self spaceForInstancesOf: cl withInstanceCount:
> instCount.
> results add: (SpaceTallyItem analyzedClassName: cl name
> codeSize: codeSpace instanceCount: instCount spaceForInstances:
> instSpace).
> totalCodeSpace := totalCodeSpace + codeSpace.
> totalInstCount := totalInstCount + instCount.
> totalInstSpace := totalInstSpace + instSpace]].
> totalPercent := 0.0.
>
> "aStream timeStamp."
> aStream
> nextPutAll: ('Class' padded: #right to: 30 with: $ );
> nextPutAll: ('code space' padded: #left to: 12 with: $ );
> nextPutAll: ('# instances' padded: #left to: 12 with: $ );
> nextPutAll: ('inst space' padded: #left to: 12 with: $ );
> nextPutAll: ('percent' padded: #left to: 8 with: $ ); cr.
>
> threshold > 0 ifTrue: [
> "If inst count threshold > 0, then sort by space"
> results := (results select: [:s | s instanceCount >= threshold
> or: [s spaceForInstances > (totalInstSpace // 500)]])
> asSortedCollection: [:s :s2 | s spaceForInstances > s2
> spaceForInstances]].
>
> results do: [:s | | percent |
> aStream
> nextPutAll: (s analyzedClassName padded: #right to: 30
> with: $ );
> nextPutAll: (s codeSize printString padded: #left to: 12
> with: $ );
> nextPutAll: (s instanceCount printString padded: #left to:
> 12 with: $ );
> nextPutAll: (s spaceForInstances printString padded: #left
> to: 14 with: $ ).
> percent := s spaceForInstances*100.0/totalInstSpace roundTo: 0.1.
> totalPercent := totalPercent + percent.
> percent >= 0.1 ifTrue: [
> aStream nextPutAll: (percent printString padded: #left to:
> 8 with: $ )].
> aStream cr].
>
> aStream
> cr; nextPutAll: ('Total' padded: #right to: 30 with: $ );
> nextPutAll: (totalCodeSpace printString padded: #left to: 12
> with: $ );
> nextPutAll: (totalInstCount printString padded: #left to: 12
> with: $ );
> nextPutAll: (totalInstSpace printString padded: #left to: 14
> with: $ );
> nextPutAll: ((totalPercent roundTo: 0.1) printString padded:
> #left to: 8 with: $ ).
>
>
>
> So....you agree with both changes?
>
> Thanks!
>
> Mariano
>
>
>
> Cheers,
> Henry
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> <mailto:Pharo-project@lists.gforge.inria.fr>
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sound good to me!
Personally I'd also like some more refactoring, like rewriting
spaceForInstancesOf: withInstanceCount into
#spaceForInstancesOfClass: aClass, delegating to:
#spaceFor: amount instancesOfClass: aFixedClass (private category?)
#spaceForInstancesOfVariableClass: aVariableClass (private category?)
That way you also move ugly instance counting out of the loop.
Also, while you're at it, what about factoring out
contentBytes > 255
ifTrue: [12]
ifFalse: [isCompact ifTrue: [4] ifFalse: [8].
into, say, #headerBytesOfClass: aClass ?
And really, wtf?
An instance of a compact, variable class with more than 255 bytes in it
will have a 12-byte header, while those with less will have a 4-byte header?
Plus, setting a class with more than 63 instance variables will never
have an effect, its instances will always have 12-byte headers?
Cheers,
Henry
Sept. 21, 2010
Re: [Pharo-project] is it possible to know the memory occupation (bytes) of an object?
by Mariano Martinez Peck
On Tue, Apr 27, 2010 at 1:19 PM, Adrian Lienhard <adi(a)netstyle.ch> wrote:
> Its a simple method in Object:
>
> Object>>sizeInMemory
> "Returns the number of bytes used by this object in memory
> (including its header)"
>
> | headerSize instanceSize |
> headerSize := (self class indexIfCompact > 0 ifTrue: [ 4 ] ifFalse:
> [ 8 ]).
> instanceSize := (self class isVariable
> ifFalse: [ self class instSize * Smalltalk wordSize ]
> ifTrue: [ (self basicSize * (self class isBytes
> ifTrue: [ 1 ] ifFalse: [ Smalltalk wordSize ])) ]).
> ^ headerSize + instanceSize
>
>
Hi Adrian. Sorry for returning to this thread. I am trying to contemplate
all the cases.
I was looking at SpaceTally and I found that maybe a better implementation
could be something like this:
Object >> sizeInMemory
"Answer the number of bytes consumed by this instance including object
header."
| isCompact instVarBytes bytesPerElement headerBytes total contentBytes
|
isCompact := self class indexIfCompact > 0.
instVarBytes := self class instSize * 4.
self class isVariable
ifTrue: [
bytesPerElement := self class isBytes ifTrue: [1] ifFalse: [4].
total := 0.
contentBytes := instVarBytes + (self basicSize *
bytesPerElement).
headerBytes :=
contentBytes > 255
ifTrue: [12]
ifFalse: [isCompact ifTrue: [4] ifFalse: [8]].
total := headerBytes + contentBytes.
^ total]
ifFalse: [
headerBytes :=
instVarBytes > 255
ifTrue: [12]
ifFalse: [isCompact ifTrue: [4] ifFalse: [8]].
^ headerBytes + instVarBytes ].
I guess I did some mistake but if we can arrive to a good implementation it
would be really cool.
Thanks
mariano
> Please also note the other mail I sent to this thread.
>
> Adrian
>
> On Apr 27, 2010, at 13:16 , Mariano Martinez Peck wrote:
>
> > On Tue, Apr 27, 2010 at 12:45 PM, Adrian Lienhard <adi(a)netstyle.ch>
> wrote:
> >
> >> I once sent some code to the mailing list (search for thread named "Size
> of
> >> objects").
> >
> >
> > Thanks Adrian...I couldn't find it. Can you forward it to me please? or
> > just send me the code...
> >
> >
> >> We should add this to the image. I think I named it #sizeInMemory.
> >>
> >>
> > There are only changes to the image side ? or the vm also ?
> >
> > Thanks
> >
> > Mariano
> >
> >
> >
> >> Adrian
> >>
> >> On Apr 27, 2010, at 12:03 , Mariano Martinez Peck wrote:
> >>
> >>> Hi. I don't know if "memory occupation" is the better name. I just want
> >> to
> >>> know the amount of memory that an object is occupying in RAM. I mean,
> the
> >>> amount of bytes.
> >>>
> >>> Is this possible ? if true, how ? I would like to do it from both
> >> sides:
> >>> image and VM.
> >>>
> >>> I checked both but I didn't find anything.
> >>>
> >>> Thanks in advance
> >>>
> >>> Mariano
> >>> _______________________________________________
> >>> Pharo-project mailing list
> >>> Pharo-project(a)lists.gforge.inria.fr
> >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >>
> >>
> >> _______________________________________________
> >> Pharo-project mailing list
> >> Pharo-project(a)lists.gforge.inria.fr
> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >>
> > _______________________________________________
> > Pharo-project mailing list
> > Pharo-project(a)lists.gforge.inria.fr
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sept. 21, 2010
Re: [Pharo-project] Tutorial of ProfStef
by laurent laffont
Fixed, thank you
Laurent
On Tue, Sep 21, 2010 at 7:43 PM, Alexandre Bergel <alexandre(a)bergel.eu>wrote:
> Hi!
>
> The idea of ProfStef is simply brilliant.
I have one comment:
> Page 2 is written:
>
> Your can use Lesson>>title:lesson: to create Lesson object.
>
> It should be Lesson class>>title:lesson:
>
> Cheers,
> Alexandre
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sept. 21, 2010
Re: [Pharo-project] [squeak-dev] Morphic
by Hilaire Fernandes
Le 20/09/2010 23:30, Levente Uzonyi a écrit :
> On Mon, 20 Sep 2010, Hilaire Fernandes wrote:
>
>> Le 20/09/2010 17:50, Levente Uzonyi a écrit :
>>> On Sat, 18 Sep 2010, Hilaire Fernandes wrote:
>>>
>>>> Really I don't understand CUIS long term objective, why this work is
>>>> not
>>>> done in Pharo? They share the same vision.
>>>
>>> You could ask the same question with Pharo and Squeak instead of Cuis
>>> and Pharo, couldn't you?
>>
>> No, I can't.
>>
>> Pharo provides me a clear vision I can thrust: a Smalltalk environment
>> to build third party applications (ie makes my developer life easier).
>> Squeak does not provide me this thrust nor indication of that direction.
>
> When was the last time you used Squeak?
In may, when I ported back istoa artifact with Etoys scripting. It was
quite pleasant to update these code within Squeak.
>
>> You can object it is matter of point of view, I will object it is a
>> matter of ressources you can allocate to write an application. Mine are
>> limited: I start writing DrGeo under Squeak, then I continued with
>> Pharo. I can really fell the difference: nice Widgets, cleaner system I
>> can understand, ease to integrate changes/improvements upstream. All in
>> all, I get the job done more nicely from my perspective.
>
> So you're using Pharo because of Polymorph?
yes, but not only.
>> In the past, project got hudge resources (ie Sophie), this project
>> failed to give back to the community in a proper way. Was it because
>
> I don't really get this, which project are you talking about?
Sophie.
Hilaire
--
Dr. Geo, to discover geometry on Linux, Windows, MAC and XO
http://community.ofset.org/index.php/DrGeo
Sept. 21, 2010
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Henrik Sperre Johansen
On 21.09.2010 20:22, Adrian Lienhard wrote:
> Here's the code I used to confirm Henrik's math:
>
> table := Unicode classPool at: 'GeneralCategory'.
> count := table basicSize.
> 1 to: table basicSize do: [ :i |
> (table basicAt: i) isNil ifFalse: [
> count := count + (table basicAt: i) basicSize ] ].
> (count / 1024) asFloat
>
> -> 66.8759765625
>
> + the headers of each subtable.
>
> Cheers,
> Adrian
Yes, except initially doing
count := table basicSize*4 (4 bytes for a slot when class isBytes not)
that's basically what I did. ~ due to not counting headers :)
Cheers,
Henry
Sept. 21, 2010
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Mariano Martinez Peck
2010/9/21 Henrik Sperre Johansen <henrik.s.johansen(a)veloxit.no>
> On 21.09.2010 20:07, Mariano Martinez Peck wrote:
>
>
>
> On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen <
> henrik.s.johansen(a)veloxit.no> wrote:
>
>> On 21.09.2010 19:10, Mariano Martinez Peck wrote:
>>
>>> Hi folks. I wasn't aware of the class SparseLargeTable but it seems it
>>> has two important instances "SparseLargeTable allInstances size -> 2"
>>>
>>> They are the class side variables #DecimalProperty and #GeneralCategory
>>> in Unicode.
>>>
>>> Actually,
>>>
>>> (Unicode classPool at: 'GeneralCategory') size -> 917632
>>>
>>> (Unicode classPool at: 'DecimalProperty') size -> 917632
>>>
>>> So...collections of almost 1 million elements.
>>>
>>> Now a couple of questions:
>>>
>>> 1) Is this normal/expected? In my calculus both arrays are like 3mb of
>>> memory
>>>
>> Look at the implementation, there's a reason they're called sparse.
>> If my math is correct (crosses fingers), DecimalProperty is ~15KB,
>> GeneralCategory ~70KB
>
>
> So...there must be a problem with my code, I was doing something like
> SpaceTally does:
>
>
> spaceForUsedInstancesOf: aClass withInstanceCount: instCount
> "Answer the number of bytes consumed by all instances of the given
> class, including their object headers."
>
> | isCompact instVarBytes bytesPerElement headerBytes total |
> instCount = 0 ifTrue: [^ 0].
> isCompact := aClass indexIfCompact > 0.
> instVarBytes := aClass instSize * 4.
> aClass isVariable
> ifTrue: [
> bytesPerElement := aClass isBytes ifTrue: [1] ifFalse: [4].
> total := 0.
> aClass allInstancesDo: [:inst | | contentBytes |
> contentBytes := instVarBytes + (inst *size* *
> bytesPerElement).
>
> There you go. Use basicSize, size is overridden by f.ex. HashedCollections
> and LargeSparseTables.
>
>
:) Thanks Henry. Now SpaceTally new spaceForInstancesOf: SparseLargeTable
withInstanceCount: 2 ->> 18748
So....I guess I should commit the fix for SpaceTally >> spaceForInstancesOf:
aClass withInstanceCount: instCount
shouldn't I ?
In addition, I modified SpaceTally >> printSpaceAnalysis: threshold on:
aStream
from this:
printSpaceAnalysis: threshold on: aStream
"SpaceTally new printSpaceAnalysis: 1 on:(FileStream forceNewFileNamed:
'STspace.text')"
"sd-This method should be rewrote to be more coherent within the rest of
the class
ie using preAllocate and spaceForInstanceOf:"
"If threshold > 0, then only those classes with more than that number
of instances will be shown, and they will be sorted by total instance
space.
If threshold = 0, then all classes will appear, sorted by name."
| totalCodeSpace totalInstCount totalInstSpace n totalPercent |
Smalltalk garbageCollect.
totalCodeSpace := totalInstCount := totalInstSpace := n := 0.
results := OrderedCollection new: Smalltalk classNames size.
'Taking statistics...'
displayProgressAt: Sensor cursorPoint
from: 0 to: Smalltalk classNames size
during: [:bar |
(Smalltalk globals allClasses) do:
[:cl | | codeSpace instCount instSpace eltSize | codeSpace := cl
spaceUsed.
bar value: (n := n+1).
Smalltalk garbageCollectMost.
instCount := cl instanceCount.
instSpace := (cl indexIfCompact > 0 ifTrue: [4] ifFalse:
[8])*instCount. "Object headers"
cl isVariable
ifTrue: [eltSize := cl isBytes ifTrue: [1] ifFalse: [4].
cl allInstancesDo: [:x | instSpace := instSpace + (x
basicSize*eltSize)]]
ifFalse: [instSpace := instSpace + (cl instSize*instCount*4)].
results add: (SpaceTallyItem analyzedClassName: cl name
codeSize: codeSpace instanceCount: instCount spaceForInstances: instSpace).
totalCodeSpace := totalCodeSpace + codeSpace.
totalInstCount := totalInstCount + instCount.
totalInstSpace := totalInstSpace + instSpace]].
totalPercent := 0.0.
"aStream timeStamp."
aStream
nextPutAll: ('Class' padded: #right to: 30 with: $ );
nextPutAll: ('code space' padded: #left to: 12 with: $ );
nextPutAll: ('# instances' padded: #left to: 12 with: $ );
nextPutAll: ('inst space' padded: #left to: 12 with: $ );
nextPutAll: ('percent' padded: #left to: 8 with: $ ); cr.
threshold > 0 ifTrue: [
"If inst count threshold > 0, then sort by space"
results := (results select: [:s | s instanceCount >= threshold or:
[s spaceForInstances > (totalInstSpace // 500)]])
asSortedCollection: [:s :s2 | s spaceForInstances > s2
spaceForInstances]].
results do: [:s | | percent |
aStream
nextPutAll: (s analyzedClassName padded: #right to: 30 with: $
);
nextPutAll: (s codeSize printString padded: #left to: 12 with: $
);
nextPutAll: (s instanceCount printString padded: #left to: 12
with: $ );
nextPutAll: (s spaceForInstances printString padded: #left to:
14 with: $ ).
percent := s spaceForInstances*100.0/totalInstSpace roundTo: 0.1.
totalPercent := totalPercent + percent.
percent >= 0.1 ifTrue: [
aStream nextPutAll: (percent printString padded: #left to: 8
with: $ )].
aStream cr].
aStream
cr; nextPutAll: ('Total' padded: #right to: 30 with: $ );
nextPutAll: (totalCodeSpace printString padded: #left to: 12 with: $
);
nextPutAll: (totalInstCount printString padded: #left to: 12 with: $
);
nextPutAll: (totalInstSpace printString padded: #left to: 14 with: $
);
nextPutAll: ((totalPercent roundTo: 0.1) printString padded: #left
to: 8 with: $ ).
To this:
printSpaceAnalysis: threshold on: aStream
"SpaceTally new printSpaceAnalysis: 1 on:(FileStream forceNewFileNamed:
'STspace.text')"
"sd-This method should be rewrote to be more coherent within the rest of
the class
ie using preAllocate and spaceForInstanceOf:"
"If threshold > 0, then only those classes with more than that number
of instances will be shown, and they will be sorted by total instance
space.
If threshold = 0, then all classes will appear, sorted by name."
| totalCodeSpace totalInstCount totalInstSpace n totalPercent |
Smalltalk garbageCollect.
totalCodeSpace := totalInstCount := totalInstSpace := n := 0.
results := OrderedCollection new: Smalltalk classNames size.
'Taking statistics...'
displayProgressAt: Sensor cursorPoint
from: 0 to: Smalltalk classNames size
during: [:bar |
(Smalltalk globals allClasses) do:
[:cl | | codeSpace instCount instSpace eltSize | codeSpace := cl
spaceUsed.
bar value: (n := n+1).
Smalltalk garbageCollectMost.
instCount := cl instanceCount.
instSpace := self spaceForInstancesOf: cl withInstanceCount:
instCount.
results add: (SpaceTallyItem analyzedClassName: cl name
codeSize: codeSpace instanceCount: instCount spaceForInstances: instSpace).
totalCodeSpace := totalCodeSpace + codeSpace.
totalInstCount := totalInstCount + instCount.
totalInstSpace := totalInstSpace + instSpace]].
totalPercent := 0.0.
"aStream timeStamp."
aStream
nextPutAll: ('Class' padded: #right to: 30 with: $ );
nextPutAll: ('code space' padded: #left to: 12 with: $ );
nextPutAll: ('# instances' padded: #left to: 12 with: $ );
nextPutAll: ('inst space' padded: #left to: 12 with: $ );
nextPutAll: ('percent' padded: #left to: 8 with: $ ); cr.
threshold > 0 ifTrue: [
"If inst count threshold > 0, then sort by space"
results := (results select: [:s | s instanceCount >= threshold or:
[s spaceForInstances > (totalInstSpace // 500)]])
asSortedCollection: [:s :s2 | s spaceForInstances > s2
spaceForInstances]].
results do: [:s | | percent |
aStream
nextPutAll: (s analyzedClassName padded: #right to: 30 with: $
);
nextPutAll: (s codeSize printString padded: #left to: 12 with: $
);
nextPutAll: (s instanceCount printString padded: #left to: 12
with: $ );
nextPutAll: (s spaceForInstances printString padded: #left to:
14 with: $ ).
percent := s spaceForInstances*100.0/totalInstSpace roundTo: 0.1.
totalPercent := totalPercent + percent.
percent >= 0.1 ifTrue: [
aStream nextPutAll: (percent printString padded: #left to: 8
with: $ )].
aStream cr].
aStream
cr; nextPutAll: ('Total' padded: #right to: 30 with: $ );
nextPutAll: (totalCodeSpace printString padded: #left to: 12 with: $
);
nextPutAll: (totalInstCount printString padded: #left to: 12 with: $
);
nextPutAll: (totalInstSpace printString padded: #left to: 14 with: $
);
nextPutAll: ((totalPercent roundTo: 0.1) printString padded: #left
to: 8 with: $ ).
So....you agree with both changes?
Thanks!
Mariano
Cheers,
> Henry
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sept. 21, 2010
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Adrian Lienhard
Here's the code I used to confirm Henrik's math:
table := Unicode classPool at: 'GeneralCategory'.
count := table basicSize.
1 to: table basicSize do: [ :i |
(table basicAt: i) isNil ifFalse: [
count := count + (table basicAt: i) basicSize ] ].
(count / 1024) asFloat
-> 66.8759765625
+ the headers of each subtable.
Cheers,
Adrian
On Sep 21, 2010, at 20:16 , Henrik Sperre Johansen wrote:
> On 21.09.2010 20:07, Mariano Martinez Peck wrote:
>>
>>
>> On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen <henrik.s.johansen(a)veloxit.no <mailto:henrik.s.johansen@veloxit.no>> wrote:
>>
>> On 21.09.2010 19:10, Mariano Martinez Peck wrote:
>>
>> Hi folks. I wasn't aware of the class SparseLargeTable but it
>> seems it has two important instances "SparseLargeTable
>> allInstances size -> 2"
>>
>> They are the class side variables #DecimalProperty and
>> #GeneralCategory in Unicode.
>>
>> Actually,
>>
>> (Unicode classPool at: 'GeneralCategory') size -> 917632
>>
>> (Unicode classPool at: 'DecimalProperty') size -> 917632
>>
>> So...collections of almost 1 million elements.
>>
>> Now a couple of questions:
>>
>> 1) Is this normal/expected? In my calculus both arrays are
>> like 3mb of memory
>>
>> Look at the implementation, there's a reason they're called sparse.
>> If my math is correct (crosses fingers), DecimalProperty is ~15KB,
>> GeneralCategory ~70KB
>>
>>
>> So...there must be a problem with my code, I was doing something like SpaceTally does:
>>
>>
>> spaceForUsedInstancesOf: aClass withInstanceCount: instCount
>> "Answer the number of bytes consumed by all instances of the given class, including their object headers."
>>
>> | isCompact instVarBytes bytesPerElement headerBytes total |
>> instCount = 0 ifTrue: [^ 0].
>> isCompact := aClass indexIfCompact > 0.
>> instVarBytes := aClass instSize * 4.
>> aClass isVariable
>> ifTrue: [
>> bytesPerElement := aClass isBytes ifTrue: [1] ifFalse: [4].
>> total := 0.
>> aClass allInstancesDo: [:inst | | contentBytes |
>> contentBytes := instVarBytes + (inst *size* * bytesPerElement).
> There you go. Use basicSize, size is overridden by f.ex. HashedCollections and LargeSparseTables.
>
> Cheers,
> Henry
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Sept. 21, 2010
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Henrik Sperre Johansen
On 21.09.2010 20:07, Mariano Martinez Peck wrote:
>
>
> On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen
> <henrik.s.johansen(a)veloxit.no <mailto:henrik.s.johansen@veloxit.no>>
> wrote:
>
> On 21.09.2010 19:10, Mariano Martinez Peck wrote:
>
> Hi folks. I wasn't aware of the class SparseLargeTable but it
> seems it has two important instances "SparseLargeTable
> allInstances size -> 2"
>
> They are the class side variables #DecimalProperty and
> #GeneralCategory in Unicode.
>
> Actually,
>
> (Unicode classPool at: 'GeneralCategory') size -> 917632
>
> (Unicode classPool at: 'DecimalProperty') size -> 917632
>
> So...collections of almost 1 million elements.
>
> Now a couple of questions:
>
> 1) Is this normal/expected? In my calculus both arrays are
> like 3mb of memory
>
> Look at the implementation, there's a reason they're called sparse.
> If my math is correct (crosses fingers), DecimalProperty is ~15KB,
> GeneralCategory ~70KB
>
>
> So...there must be a problem with my code, I was doing something like
> SpaceTally does:
>
>
> spaceForUsedInstancesOf: aClass withInstanceCount: instCount
> "Answer the number of bytes consumed by all instances of the given
> class, including their object headers."
>
> | isCompact instVarBytes bytesPerElement headerBytes total |
> instCount = 0 ifTrue: [^ 0].
> isCompact := aClass indexIfCompact > 0.
> instVarBytes := aClass instSize * 4.
> aClass isVariable
> ifTrue: [
> bytesPerElement := aClass isBytes ifTrue: [1] ifFalse: [4].
> total := 0.
> aClass allInstancesDo: [:inst | | contentBytes |
> contentBytes := instVarBytes + (inst *size* *
> bytesPerElement).
There you go. Use basicSize, size is overridden by f.ex.
HashedCollections and LargeSparseTables.
Cheers,
Henry
Sept. 21, 2010
Re: [Pharo-project] Issue 2744: Renaming the path to the image is not caught in Pharo on OS X
by Guillermo Polito
But if the changes file is pointed as "./myImage.changes" instead of
"/home/mariano/pharo/myImage.changes" the problem will not exist.
But I don't know if the vm supports relative paths...
2010/9/21 Mariano Martinez Peck <marianopeck(a)gmail.com>
>
>
> 2010/9/21 Guillermo Polito <guillermopolito(a)gmail.com>
>
>
>>
>> 2010/9/21 Mariano Martinez Peck <marianopeck(a)gmail.com>
>>
>> Yes, I have this probelm several times....what I did is to change the
>>>
>>> logChange: so that it does nothing, save it, and then quit the image.
>>>
>>>
>>> Anyway, what could be a solution for this problem?
>>>
>>
>> Relative paths? :/
>>
>>
>
> No, it won't wotk.
>
> Suppose my .image and .changes are now in /home/mariano/Pharo and while
> the image is running you rename the directory to /home/mariano/pharoRenamed
>
> Your smalltalk image is still pointing to your .changes in
> /home/mariano/Pharo and it was not updated.
>
> So...the only way I see is that the OS somehow should notify SqueakVM about
> that.....
>
>
>
>>
>>> thanks
>>>
>>> mariano
>>>
>>>
>>> On Tue, Aug 3, 2010 at 3:28 PM, Mircea Lungu <lungu(a)iam.unibe.ch> wrote:
>>>
>>>> Hi guys,
>>>>
>>>> If I rename any of the directories in the path of a running image I will
>>>> break the image: I can't save it, I can't close it. I get a debugger
>>>> at any step. It seems the image is not informed of the path change
>>>> and it still tries to log the changes in the the changes file which has
>>>> already moved.
>>>>
>>>> I verified this on OS X,.
>>>>
>>>> I opened an issue for this:
>>>> http://code.google.com/p/pharo/issues/detail?id=2744
>>>>
>>>> Mircea.
>>>>
>>>> _______________________________________________
>>>> Pharo-project mailing list
>>>> Pharo-project(a)lists.gforge.inria.fr
>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>>
>>>
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> Pharo-project(a)lists.gforge.inria.fr
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project(a)lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sept. 21, 2010
Re: [Pharo-project] SparseLargeTable instances and Unicode
by Mariano Martinez Peck
On Tue, Sep 21, 2010 at 7:55 PM, Henrik Sperre Johansen <
henrik.s.johansen(a)veloxit.no> wrote:
> On 21.09.2010 19:10, Mariano Martinez Peck wrote:
>
>> Hi folks. I wasn't aware of the class SparseLargeTable but it seems it has
>> two important instances "SparseLargeTable allInstances size -> 2"
>>
>> They are the class side variables #DecimalProperty and #GeneralCategory in
>> Unicode.
>>
>> Actually,
>>
>> (Unicode classPool at: 'GeneralCategory') size -> 917632
>>
>> (Unicode classPool at: 'DecimalProperty') size -> 917632
>>
>> So...collections of almost 1 million elements.
>>
>> Now a couple of questions:
>>
>> 1) Is this normal/expected? In my calculus both arrays are like 3mb of
>> memory
>>
> Look at the implementation, there's a reason they're called sparse.
> If my math is correct (crosses fingers), DecimalProperty is ~15KB,
> GeneralCategory ~70KB
So...there must be a problem with my code, I was doing something like
SpaceTally does:
spaceForUsedInstancesOf: aClass withInstanceCount: instCount
"Answer the number of bytes consumed by all instances of the given
class, including their object headers."
| isCompact instVarBytes bytesPerElement headerBytes total |
instCount = 0 ifTrue: [^ 0].
isCompact := aClass indexIfCompact > 0.
instVarBytes := aClass instSize * 4.
aClass isVariable
ifTrue: [
bytesPerElement := aClass isBytes ifTrue: [1] ifFalse: [4].
total := 0.
aClass allInstancesDo: [:inst | | contentBytes |
contentBytes := instVarBytes + (inst size *
bytesPerElement).
headerBytes :=
contentBytes > 255
ifTrue: [12]
ifFalse: [isCompact ifTrue: [4] ifFalse: [8]].
(UnusedObjectDiscoverer current primitiveGetUsedBit:
inst) ifTrue:
[total := total + headerBytes + contentBytes]].
^ total]
ifFalse: [
headerBytes :=
instVarBytes > 255
ifTrue: [12]
ifFalse: [isCompact ifTrue: [4] ifFalse: [8]].
^ instCount * (headerBytes + instVarBytes)].
SparseLargeTable instanceCount ->>> 2
SpaceTally new spaceForUsedInstancesOf: SparseLargeTable withInstanceCount:
2 ->>> 7341112
thanks
>
>
>> 2) If I don't use UTF and I send an encoding as parameter in the VM
>> (different from UTF), do I need this class side variables?
>>
> What Lukas said.
>
> Cheers,
> Henry
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
Sept. 21, 2010