Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- October
- 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
- 144621 messages
Re: [Pharo-project] Small Seaside image
by laurent laffont
Thanks for your help all.
My steps:
- Seaside/Magritte: load only what's needed for SmallHarbour
- load Zinc-Seaside instead of Comanche
- cleanUpForProduction
- zapOrganization
I now have a 10MB image.
Laurent.
On Wed, Aug 3, 2011 at 10:38 AM, Mariano Martinez Peck <
marianopeck(a)gmail.com> wrote:
> Hi Laurent. First, as Marcus said, there is no magic. You should really
> load the packages of seaside and all the minimal dependes. Just load what
> you need. Once you are done, evaluate ScriptLoader new cleanUpForRelease.
> But take a look to what that method does.
> Then, if you are sure you don't need certain packages from pharo core,
> thanks to the better modularization we have, you can remove it. Esteban did
> that for his images for iPhone.
>
> There are also some shrink you can do. For example,
> "To put all all classes with the default category. Still can browse and
> recompile the whole image.
> Most production enviroments don't care about categories...this make sense
> when developing."
>
> Smalltalk allClassesAndTraitsDo: [:each | each zapOrganization ].
>
> how much did it help?
>
> Fonts. Do you need al fonts? no...remove them.
>
> etc...
>
>
>
> On Wed, Aug 3, 2011 at 10:24 AM, Marcus Denker <marcus.denker(a)inria.fr>wrote:
>
>>
>> On Aug 3, 2011, at 10:17 AM, laurent laffont wrote:
>>
>> > Hi,
>> >
>> > actually using PharoCore 1.3, loading ConfigurationOfSeaside30 Core,
>> then ScriptLoader>>cleanUpForProduction I have a 13MB image. Is it possible
>> to have it smaller ? (I know a next step is to be able to use PharoKernel).
>>
>> cleanUpForProduction should result in a Core image that is just 6.5MB...
>> so the ConfigurationOfSeaside30 seems to load *a lot* of stuff? Maybe be a
>> bit selective?
>>
>> Marcus
>>
>>
>> --
>> Marcus Denker -- http://marcusdenker.de
>>
>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Mariano Martinez Peck
On Wed, Aug 3, 2011 at 10:47 PM, Igor Stasenko <siguctua(a)gmail.com> wrote:
> On 3 August 2011 22:27, Stéphane Ducasse <stephane.ducasse(a)inria.fr>
> wrote:
> > How can we test and make sure that in the future we know automatically if
> the weak is broken?
> >
>
> object := Object new.
>
> coll := WeakOrderedCollection new add: anObject.
> anObject := nil.
> Smalltalk garbageCollect.
> self assert: coll removeLast isNil
>
That was not enought in this case. In fact, it was really difficult for me
to find the bug, because it used to ONLY fail when sending #grow.
(WeakOrderedCollection new instVarNamed: 'array') class ->>>> WeakArray
(WeakOrderedCollection new grow instVarNamed: 'array') class ->>>> Array
:)
> :)
>
> > Stef
> >
> > On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
> >
> >> You replace Array with self arrayType, that's all.
> >> But there is better, Pharo already has growAtFirst and growAtLast
> >> which are correct.
> >> Use them instead of grow.
> >> See SLICE in inbox.
> >>
> >> Nicolas
> >>
> >> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >>> btw...how can I change OrderedCollection>>grow
> >>> without shooting my foots?
> >>>
> >>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> >>> <marianopeck(a)gmail.com> wrote:
> >>>>
> >>>>
> >>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> >>>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
> >>>>>
> >>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is
> no
> >>>>> more a WeakArray but a simple Array.
> >>>>
> >>>> Yes, indeed, it is a normal Array and that cought my attention. But
> since
> >>>> I have no idea about Weak stuff...I also noticed that
> WeakOrderedCollection
> >>>> is declared as:
> >>>>
> >>>> OrderedCollection subclass: #WeakOrderedCollection
> >>>> instanceVariableNames: ''
> >>>> classVariableNames: ''
> >>>> poolDictionaries: ''
> >>>> category: 'Collections-Weak'
> >>>>
> >>>> instead of using the #weakSubclass: ... message:
> >>>>
> >>>> OrderedCollection weakSubclass: #WeakOrderedCollection
> >>>> instanceVariableNames: ''
> >>>> classVariableNames: ''
> >>>> poolDictionaries: ''
> >>>> category: 'Collections-Weak'
> >>>>
> >>>>
> >>>>>
> >>>>> This is because Pharo's WeakOrderedCollection is broken...
> >>>>>
> >>>>
> >>>> Do you know a weak collection that is not broken in Pharo and let me
> do a
> >>>> addLast: ?
> >>>>
> >>>>>
> >>>>> Every reference to Array from within OrderedCollection should be
> >>>>> replaced with message send (self arrayType).
> >>>>> See for example, OrderedCollection>>#grow
> >>>>>
> >>>>
> >>>> Thanks. I will check how many there are and try to fix them.
> >>>>
> >>>>>
> >>>>> Nicolas
> >>>>>
> >>>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >>>>>> Hi guys. I am since yesterday trying to find something and I cannot.
> So
> >>>>>> at
> >>>>>> this point I need external eyes :)
> >>>>>> I have this little code:
> >>>>>>
> >>>>>> anObject := ClassWith2Var new.
> >>>>>> sharedObject := ClassWith1Var new.
> >>>>>> sharedObject var1: 'nose'.
> >>>>>> anObject var1: Date today.
> >>>>>> anObject var2: sharedObject.
> >>>>>>
> >>>>>> serializedObjects := FuelMareaSerializer new
> >>>>>> serializeAndWriteObject:
> >>>>>> anObject to: 'aFileName'.
> >>>>>> anObject := nil.
> >>>>>> sharedObject := nil.
> >>>>>>
> >>>>>> 3 timesRepeat: [Smalltalk garbageCollect].
> >>>>>> serializedObjects inspect.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> What is important here is that FuelMareaSerializer new
> >>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
> >>>>>> WeakOrderedCollection with each object of the serialized graph
> (taking
> >>>>>> anObject as the root)
> >>>>>> Now, if I print the tempVar serializedObjects I see:
> >>>>>>
> >>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> >>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> >>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
> 0
> >>>>>> 7200)
> >>>>>>
> >>>>>> WHYYYY?? why are all there if I put a nil to both, anObject and
> >>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
> >>>>>> (except
> >>>>>> classes). Why are not being garbage collected?
> >>>>>>
> >>>>>> If I explore, for example the tempVar sharedObejct, which is at
> >>>>>> serializedObjects at: 6 and then I put explore pointers I ONLY see
> >>>>>> the
> >>>>>> array of the WeakOrderedCollection pointing to it. I don't
> understand.
> >>>>>>
> >>>>>> Any help is really appreaciated.
> >>>>>>
> >>>>>> --
> >>>>>> Mariano
> >>>>>> http://marianopeck.wordpress.com
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Mariano
> >>>> http://marianopeck.wordpress.com
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Mariano
> >>> http://marianopeck.wordpress.com
> >>>
> >>>
> >>
> >
> >
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
--
Mariano
http://marianopeck.wordpress.com
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Igor Stasenko
On 3 August 2011 22:27, Stéphane Ducasse <stephane.ducasse(a)inria.fr> wrote:
> How can we test and make sure that in the future we know automatically if the weak is broken?
>
object := Object new.
coll := WeakOrderedCollection new add: anObject.
anObject := nil.
Smalltalk garbageCollect.
self assert: coll removeLast isNil
:)
> Stef
>
> On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
>
>> You replace Array with self arrayType, that's all.
>> But there is better, Pharo already has growAtFirst and growAtLast
>> which are correct.
>> Use them instead of grow.
>> See SLICE in inbox.
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>> btw...how can I change OrderedCollection>>grow
>>> without shooting my foots?
>>>
>>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>>> <marianopeck(a)gmail.com> wrote:
>>>>
>>>>
>>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>>>
>>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>>> more a WeakArray but a simple Array.
>>>>
>>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>>> is declared as:
>>>>
>>>> OrderedCollection subclass: #WeakOrderedCollection
>>>> Â Â instanceVariableNames: ''
>>>> Â Â classVariableNames: ''
>>>> Â Â poolDictionaries: ''
>>>> Â Â category: 'Collections-Weak'
>>>>
>>>> instead of using the #weakSubclass: ... message:
>>>>
>>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>> Â Â instanceVariableNames: ''
>>>> Â Â classVariableNames: ''
>>>> Â Â poolDictionaries: ''
>>>> Â Â category: 'Collections-Weak'
>>>>
>>>>
>>>>>
>>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>>
>>>>
>>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>>> addLast: ?
>>>>
>>>>>
>>>>> Every reference to Array from within OrderedCollection should be
>>>>> replaced with message send (self arrayType).
>>>>> See for example, OrderedCollection>>#grow
>>>>>
>>>>
>>>> Thanks. I will check how many there are and try to fix them.
>>>>
>>>>>
>>>>> Nicolas
>>>>>
>>>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>>> at
>>>>>> this point I need external eyes :)
>>>>>> I have this little code:
>>>>>>
>>>>>> Â Â anObject := ClassWith2Var new.
>>>>>> Â Â sharedObject := ClassWith1Var new.
>>>>>> Â Â sharedObject var1: 'nose'.
>>>>>> Â Â anObject var1: Date today.
>>>>>> Â Â anObject var2: sharedObject.
>>>>>>
>>>>>> Â Â serializedObjects := FuelMareaSerializer new
>>>>>> serializeAndWriteObject:
>>>>>> anObject to: 'aFileName'.
>>>>>> Â Â anObject := nil.
>>>>>> Â Â sharedObject := nil.
>>>>>>
>>>>>> Â Â 3 timesRepeat: [Smalltalk garbageCollect].
>>>>>> Â Â serializedObjects inspect.
>>>>>>
>>>>>>
>>>>>>
>>>>>> What is important here is that FuelMareaSerializer new
>>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>>> anObject as the root)
>>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>>
>>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>>> 7200)
>>>>>>
>>>>>> WHYYYY?? Â why are all there if I put a nil to both, anObject and
>>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>>> (except
>>>>>> classes). Why are not being garbage collected?
>>>>>>
>>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>>> serializedObjects at: 6 Â and then I put explore pointers I ONLY see
>>>>>> the
>>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>>
>>>>>> Any help is really appreaciated.
>>>>>>
>>>>>> --
>>>>>> Mariano
>>>>>> http://marianopeck.wordpress.com
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Mariano
>>>> http://marianopeck.wordpress.com
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>>
>>
>
>
>
--
Best regards,
Igor Stasenko AKA sig.
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Igor Stasenko
On 3 August 2011 12:51, Mariano Martinez Peck <marianopeck(a)gmail.com> wrote:
>
>
> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>
>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>> more a WeakArray but a simple Array.
>
> Yes, indeed, it is a normal Array and that cought my attention. But since I
> have no idea about Weak stuff...I also noticed that WeakOrderedCollection is
> declared as:
>
> OrderedCollection subclass: #WeakOrderedCollection
> Â Â Â instanceVariableNames: ''
> Â Â Â classVariableNames: ''
> Â Â Â poolDictionaries: ''
> Â Â Â category: 'Collections-Weak'
>
> instead of using the #weakSubclass: ... message:
>
> OrderedCollection weakSubclass: #WeakOrderedCollection
> Â Â Â instanceVariableNames: ''
> Â Â Â classVariableNames: ''
> Â Â Â poolDictionaries: ''
> Â Â Â category: 'Collections-Weak'
>
no you don't need that, because ordered collection contains is
elements in its array,
and to make it 'weak' you have to make the container to hold elements weakly,
but not the wrapper class, which should hold it's array strongly.
>
>>
>> This is because Pharo's WeakOrderedCollection is broken...
>>
>
> Do you know a weak collection that is not broken in Pharo and let me do a
> addLast: ?
>
>>
>> Every reference to Array from within OrderedCollection should be
>> replaced with message send (self arrayType).
>> See for example, OrderedCollection>>#grow
>>
>
> Thanks. I will check how many there are and try to fix them.
>
>>
>> Nicolas
>>
>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>> > Hi guys. I am since yesterday trying to find something and I cannot. So
>> > at
>> > this point I need external eyes :)
>> > I have this little code:
>> >
>> > Â Â Â anObject := ClassWith2Var new.
>> > Â Â Â sharedObject := ClassWith1Var new.
>> > Â Â Â sharedObject var1: 'nose'.
>> > Â Â Â anObject var1: Date today.
>> > Â Â Â anObject var2: sharedObject.
>> >
>> > Â Â Â serializedObjects := FuelMareaSerializer new
>> > serializeAndWriteObject:
>> > anObject to: 'aFileName'.
>> > Â Â Â anObject := nil.
>> > Â Â Â sharedObject := nil.
>> >
>> > Â Â Â 3 timesRepeat: [Smalltalk garbageCollect].
>> > Â Â Â serializedObjects inspect.
>> >
>> >
>> >
>> > What is important here is that FuelMareaSerializer new
>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
>> > WeakOrderedCollection with each object of the serialized graph (taking
>> > anObject as the root)
>> > Now, if I print the tempVar serializedObjects I see:
>> >
>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>> > 7200)
>> >
>> > WHYYYY?? why are all there if I put a nil to both, anObject and
>> > sharedObejct. This WeakOrderedCollection should be with all nils (except
>> > classes). Why are not being garbage collected?
>> >
>> > If I explore, for example the tempVar sharedObejct, which is at
>> > serializedObjects at: 6Â Â and then I put explore pointers I ONLY see the
>> > array of the WeakOrderedCollection pointing to it. I don't understand.
>> >
>> > Any help is really appreaciated.
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
--
Best regards,
Igor Stasenko AKA sig.
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Stéphane Ducasse
Thanks
I will have a look tomorrow morning, before packing to get back in the deep north (of France henrik).
On Aug 3, 2011, at 2:45 PM, Mariano Martinez Peck wrote:
> Ok, I have splitted the slice in two parts: PART1 and PART2. PART1 includes the fixes in #makeRoomAtFirst and #makeRoomAtLast and a new class WeakOrderedCollectionTest with two tests: #testWeakOrderedCollectionSomeGarbageCollected and #testWeakOrderedCollectionAllGarbageCollected.
>
> Those tests can be improved a lot and make them look like those in WeakSetTest where each collection operation is tested. I don't have the time/knowledge to do that right now, but if someone can, excellent.
>
> The second part is just the revome of OrderedCollection >> grow.
>
>
> Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART1-MarianoMartinezPeck.1
> Author: MarianoMartinezPeck
> Time: 3 August 2011, 2:40:10 pm
> UUID: 35f20200-98ef-581f-1100-000044ef581f
> Ancestors:
> Dependencies: CollectionsTests-MarianoMartinezPeck.529, Collections-Sequenceable-MarianoMartinezPeck.97
>
> This is the first part. It includes the fix and 2 tests.
>
>
>
>
> Name: SLICE-Issue-4596-WeakOrderedColllection-array-is-replaced-by-an-Array-instead-of-a-WeakArray-PART2-MarianoMartinezPeck.1
> Author: MarianoMartinezPeck
> Time: 3 August 2011, 2:41:42 pm
> UUID: caf00200-1007-401f-18ec-0e0008e05c1f
> Ancestors:
> Dependencies: Collections-Sequenceable-MarianoMartinezPeck.98
>
> It just removes OrderedCollection >> grow
>
>
>
> On Wed, Aug 3, 2011 at 2:11 PM, Mariano Martinez Peck <marianopeck(a)gmail.com> wrote:
> Thanks a lot Nicolas and Henrik. I have split the slice and it works!
> I will upload soon both slides, part1 and part2 and a test for it.
>
> On Wed, Aug 3, 2011 at 1:49 PM, Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com> wrote:
> Oh I see, for the SLICE, this is again the Pharo's version of
> MCPackageLoader>>basicLoad which is striking.
> In Squeak trunk it would work because removals are performed AFTER
> methodAdditions/Changes.
> In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
> split in two parts...
> Or you can just manually merge it (apply the removal after...).
>
> I'm eager to see a true atomic load with a single massive becomeForward: :)
> IMHO, this should be coupled with lazy initializations mechanism as I
> proposed once (based on pragmas).
>
> Now if you simply modify grow from within a browser, I see no obvious
> reason why it would fail...
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >
> >
> > On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
> > <nicolas.cellier.aka.nice(a)gmail.com> wrote:
> >>
> >> You replace Array with self arrayType, that's all.
> >
> > Here my images freezes and CPU goes 100%. I guess because compiling/saving a
> > method uses OrderedCollection grow at the same time.
> >
> >>
> >> But there is better, Pharo already has growAtFirst and growAtLast
> >> which are correct.
> >> Use them instead of grow.
> >> See SLICE in inbox.
> >
> > I cannot load it since it freezes in "Cleaning Up". It can be the same
> > reason as why I cannot save the modification.
> > I am in Pharo1.3
> > Latest update: #13277
> >
> > Thanks a lot for the help!
> >
> >>
> >> Nicolas
> >>
> >> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >> > btw...how can I change OrderedCollection>>grow
> >> > without shooting my foots?
> >> >
> >> > On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> >> > <marianopeck(a)gmail.com> wrote:
> >> >>
> >> >>
> >> >> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> >> >> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
> >> >>>
> >> >>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
> >> >>> more a WeakArray but a simple Array.
> >> >>
> >> >> Yes, indeed, it is a normal Array and that cought my attention. But
> >> >> since
> >> >> I have no idea about Weak stuff...I also noticed that
> >> >> WeakOrderedCollection
> >> >> is declared as:
> >> >>
> >> >> OrderedCollection subclass: #WeakOrderedCollection
> >> >> instanceVariableNames: ''
> >> >> classVariableNames: ''
> >> >> poolDictionaries: ''
> >> >> category: 'Collections-Weak'
> >> >>
> >> >> instead of using the #weakSubclass: ... message:
> >> >>
> >> >> OrderedCollection weakSubclass: #WeakOrderedCollection
> >> >> instanceVariableNames: ''
> >> >> classVariableNames: ''
> >> >> poolDictionaries: ''
> >> >> category: 'Collections-Weak'
> >> >>
> >> >>
> >> >>>
> >> >>> This is because Pharo's WeakOrderedCollection is broken...
> >> >>>
> >> >>
> >> >> Do you know a weak collection that is not broken in Pharo and let me do
> >> >> a
> >> >> addLast: ?
> >> >>
> >> >>>
> >> >>> Every reference to Array from within OrderedCollection should be
> >> >>> replaced with message send (self arrayType).
> >> >>> See for example, OrderedCollection>>#grow
> >> >>>
> >> >>
> >> >> Thanks. I will check how many there are and try to fix them.
> >> >>
> >> >>>
> >> >>> Nicolas
> >> >>>
> >> >>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >> >>> > Hi guys. I am since yesterday trying to find something and I cannot.
> >> >>> > So
> >> >>> > at
> >> >>> > this point I need external eyes :)
> >> >>> > I have this little code:
> >> >>> >
> >> >>> > anObject := ClassWith2Var new.
> >> >>> > sharedObject := ClassWith1Var new.
> >> >>> > sharedObject var1: 'nose'.
> >> >>> > anObject var1: Date today.
> >> >>> > anObject var2: sharedObject.
> >> >>> >
> >> >>> > serializedObjects := FuelMareaSerializer new
> >> >>> > serializeAndWriteObject:
> >> >>> > anObject to: 'aFileName'.
> >> >>> > anObject := nil.
> >> >>> > sharedObject := nil.
> >> >>> >
> >> >>> > 3 timesRepeat: [Smalltalk garbageCollect].
> >> >>> > serializedObjects inspect.
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > What is important here is that FuelMareaSerializer new
> >> >>> > serializeAndWriteObject: anObject to: 'aFileName' answers a
> >> >>> > WeakOrderedCollection with each object of the serialized graph
> >> >>> > (taking
> >> >>> > anObject as the root)
> >> >>> > Now, if I print the tempVar serializedObjects I see:
> >> >>> >
> >> >>> > a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> >> >>> > Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> >> >>> > 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
> >> >>> > 0
> >> >>> > 7200)
> >> >>> >
> >> >>> > WHYYYY?? why are all there if I put a nil to both, anObject and
> >> >>> > sharedObejct. This WeakOrderedCollection should be with all nils
> >> >>> > (except
> >> >>> > classes). Why are not being garbage collected?
> >> >>> >
> >> >>> > If I explore, for example the tempVar sharedObejct, which is at
> >> >>> > serializedObjects at: 6 and then I put explore pointers I ONLY see
> >> >>> > the
> >> >>> > array of the WeakOrderedCollection pointing to it. I don't
> >> >>> > understand.
> >> >>> >
> >> >>> > Any help is really appreaciated.
> >> >>> >
> >> >>> > --
> >> >>> > Mariano
> >> >>> > http://marianopeck.wordpress.com
> >> >>> >
> >> >>> >
> >> >>>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Mariano
> >> >> http://marianopeck.wordpress.com
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Mariano
> >> > http://marianopeck.wordpress.com
> >> >
> >> >
> >>
> >
> >
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> >
> >
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Mariano Martinez Peck
On Wed, Aug 3, 2011 at 10:27 PM, Stéphane Ducasse <stephane.ducasse(a)inria.fr
> wrote:
> How can we test and make sure that in the future we know automatically if
> the weak is broken?
>
>
If you check the issue traker, I've uploaded to tests for this case.
> Stef
>
> On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
>
> > You replace Array with self arrayType, that's all.
> > But there is better, Pharo already has growAtFirst and growAtLast
> > which are correct.
> > Use them instead of grow.
> > See SLICE in inbox.
> >
> > Nicolas
> >
> > 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >> btw...how can I change OrderedCollection>>grow
> >> without shooting my foots?
> >>
> >> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
> >> <marianopeck(a)gmail.com> wrote:
> >>>
> >>>
> >>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
> >>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
> >>>>
> >>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
> >>>> more a WeakArray but a simple Array.
> >>>
> >>> Yes, indeed, it is a normal Array and that cought my attention. But
> since
> >>> I have no idea about Weak stuff...I also noticed that
> WeakOrderedCollection
> >>> is declared as:
> >>>
> >>> OrderedCollection subclass: #WeakOrderedCollection
> >>> instanceVariableNames: ''
> >>> classVariableNames: ''
> >>> poolDictionaries: ''
> >>> category: 'Collections-Weak'
> >>>
> >>> instead of using the #weakSubclass: ... message:
> >>>
> >>> OrderedCollection weakSubclass: #WeakOrderedCollection
> >>> instanceVariableNames: ''
> >>> classVariableNames: ''
> >>> poolDictionaries: ''
> >>> category: 'Collections-Weak'
> >>>
> >>>
> >>>>
> >>>> This is because Pharo's WeakOrderedCollection is broken...
> >>>>
> >>>
> >>> Do you know a weak collection that is not broken in Pharo and let me do
> a
> >>> addLast: ?
> >>>
> >>>>
> >>>> Every reference to Array from within OrderedCollection should be
> >>>> replaced with message send (self arrayType).
> >>>> See for example, OrderedCollection>>#grow
> >>>>
> >>>
> >>> Thanks. I will check how many there are and try to fix them.
> >>>
> >>>>
> >>>> Nicolas
> >>>>
> >>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >>>>> Hi guys. I am since yesterday trying to find something and I cannot.
> So
> >>>>> at
> >>>>> this point I need external eyes :)
> >>>>> I have this little code:
> >>>>>
> >>>>> anObject := ClassWith2Var new.
> >>>>> sharedObject := ClassWith1Var new.
> >>>>> sharedObject var1: 'nose'.
> >>>>> anObject var1: Date today.
> >>>>> anObject var2: sharedObject.
> >>>>>
> >>>>> serializedObjects := FuelMareaSerializer new
> >>>>> serializeAndWriteObject:
> >>>>> anObject to: 'aFileName'.
> >>>>> anObject := nil.
> >>>>> sharedObject := nil.
> >>>>>
> >>>>> 3 timesRepeat: [Smalltalk garbageCollect].
> >>>>> serializedObjects inspect.
> >>>>>
> >>>>>
> >>>>>
> >>>>> What is important here is that FuelMareaSerializer new
> >>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
> >>>>> WeakOrderedCollection with each object of the serialized graph
> (taking
> >>>>> anObject as the root)
> >>>>> Now, if I print the tempVar serializedObjects I see:
> >>>>>
> >>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
> >>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
> >>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
> 0
> >>>>> 7200)
> >>>>>
> >>>>> WHYYYY?? why are all there if I put a nil to both, anObject and
> >>>>> sharedObejct. This WeakOrderedCollection should be with all nils
> >>>>> (except
> >>>>> classes). Why are not being garbage collected?
> >>>>>
> >>>>> If I explore, for example the tempVar sharedObejct, which is at
> >>>>> serializedObjects at: 6 and then I put explore pointers I ONLY see
> >>>>> the
> >>>>> array of the WeakOrderedCollection pointing to it. I don't
> understand.
> >>>>>
> >>>>> Any help is really appreaciated.
> >>>>>
> >>>>> --
> >>>>> Mariano
> >>>>> http://marianopeck.wordpress.com
> >>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Mariano
> >>> http://marianopeck.wordpress.com
> >>>
> >>
> >>
> >>
> >> --
> >> Mariano
> >> http://marianopeck.wordpress.com
> >>
> >>
> >
>
>
>
--
Mariano
http://marianopeck.wordpress.com
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Stéphane Ducasse
On Aug 3, 2011, at 1:49 PM, Nicolas Cellier wrote:
> Oh I see, for the SLICE, this is again the Pharo's version of
> MCPackageLoader>>basicLoad which is striking.
> In Squeak trunk it would work because removals are performed AFTER
> methodAdditions/Changes.
> In Pharo, removals are performed BEFORE, so yes, the SLICE needs to be
> split in two parts...
> Or you can just manually merge it (apply the removal after...).
oops we should fix that
> I'm eager to see a true atomic load with a single massive becomeForward: :)
Yes me too
> IMHO, this should be coupled with lazy initializations mechanism as I
> proposed once (based on pragmas).
Can you point us to that?
>
> Now if you simply modify grow from within a browser, I see no obvious
> reason why it would fail...
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>
>>
>> On Wed, Aug 3, 2011 at 1:01 PM, Nicolas Cellier
>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>
>>> You replace Array with self arrayType, that's all.
>>
>> Here my images freezes and CPU goes 100%. I guess because compiling/saving a
>> method uses OrderedCollection grow at the same time.
>>
>>>
>>> But there is better, Pharo already has growAtFirst and growAtLast
>>> which are correct.
>>> Use them instead of grow.
>>> See SLICE in inbox.
>>
>> I cannot load it since it freezes in "Cleaning Up". It can be the same
>> reason as why I cannot save the modification.
>> I am in Pharo1.3
>> Latest update: #13277
>>
>> Thanks a lot for the help!
>>
>>>
>>> Nicolas
>>>
>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>>> btw...how can I change OrderedCollection>>grow
>>>> without shooting my foots?
>>>>
>>>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>>>> <marianopeck(a)gmail.com> wrote:
>>>>>
>>>>>
>>>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>>>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>>>>
>>>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>>>> more a WeakArray but a simple Array.
>>>>>
>>>>> Yes, indeed, it is a normal Array and that cought my attention. But
>>>>> since
>>>>> I have no idea about Weak stuff...I also noticed that
>>>>> WeakOrderedCollection
>>>>> is declared as:
>>>>>
>>>>> OrderedCollection subclass: #WeakOrderedCollection
>>>>> instanceVariableNames: ''
>>>>> classVariableNames: ''
>>>>> poolDictionaries: ''
>>>>> category: 'Collections-Weak'
>>>>>
>>>>> instead of using the #weakSubclass: ... message:
>>>>>
>>>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>>>> instanceVariableNames: ''
>>>>> classVariableNames: ''
>>>>> poolDictionaries: ''
>>>>> category: 'Collections-Weak'
>>>>>
>>>>>
>>>>>>
>>>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>>>
>>>>>
>>>>> Do you know a weak collection that is not broken in Pharo and let me do
>>>>> a
>>>>> addLast: ?
>>>>>
>>>>>>
>>>>>> Every reference to Array from within OrderedCollection should be
>>>>>> replaced with message send (self arrayType).
>>>>>> See for example, OrderedCollection>>#grow
>>>>>>
>>>>>
>>>>> Thanks. I will check how many there are and try to fix them.
>>>>>
>>>>>>
>>>>>> Nicolas
>>>>>>
>>>>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>>>>>> Hi guys. I am since yesterday trying to find something and I cannot.
>>>>>>> So
>>>>>>> at
>>>>>>> this point I need external eyes :)
>>>>>>> I have this little code:
>>>>>>>
>>>>>>> anObject := ClassWith2Var new.
>>>>>>> sharedObject := ClassWith1Var new.
>>>>>>> sharedObject var1: 'nose'.
>>>>>>> anObject var1: Date today.
>>>>>>> anObject var2: sharedObject.
>>>>>>>
>>>>>>> serializedObjects := FuelMareaSerializer new
>>>>>>> serializeAndWriteObject:
>>>>>>> anObject to: 'aFileName'.
>>>>>>> anObject := nil.
>>>>>>> sharedObject := nil.
>>>>>>>
>>>>>>> 3 timesRepeat: [Smalltalk garbageCollect].
>>>>>>> serializedObjects inspect.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> What is important here is that FuelMareaSerializer new
>>>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>>>> WeakOrderedCollection with each object of the serialized graph
>>>>>>> (taking
>>>>>>> anObject as the root)
>>>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>>>
>>>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose'
>>>>>>> 0
>>>>>>> 7200)
>>>>>>>
>>>>>>> WHYYYY?? why are all there if I put a nil to both, anObject and
>>>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>>>> (except
>>>>>>> classes). Why are not being garbage collected?
>>>>>>>
>>>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>>>> serializedObjects at: 6 and then I put explore pointers I ONLY see
>>>>>>> the
>>>>>>> array of the WeakOrderedCollection pointing to it. I don't
>>>>>>> understand.
>>>>>>>
>>>>>>> Any help is really appreaciated.
>>>>>>>
>>>>>>> --
>>>>>>> Mariano
>>>>>>> http://marianopeck.wordpress.com
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Mariano
>>>>> http://marianopeck.wordpress.com
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Mariano
>>>> http://marianopeck.wordpress.com
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>
Aug. 3, 2011
Re: [Pharo-project] Help with a WeakOrderedCollection and objects not being GCed
by Stéphane Ducasse
How can we test and make sure that in the future we know automatically if the weak is broken?
Stef
On Aug 3, 2011, at 1:01 PM, Nicolas Cellier wrote:
> You replace Array with self arrayType, that's all.
> But there is better, Pharo already has growAtFirst and growAtLast
> which are correct.
> Use them instead of grow.
> See SLICE in inbox.
>
> Nicolas
>
> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>> btw...how can I change OrderedCollection>>grow
>> without shooting my foots?
>>
>> On Wed, Aug 3, 2011 at 12:51 PM, Mariano Martinez Peck
>> <marianopeck(a)gmail.com> wrote:
>>>
>>>
>>> On Wed, Aug 3, 2011 at 12:42 PM, Nicolas Cellier
>>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>>
>>>> I'm pretty sure the array inst var of your WeakOrderedColleciton is no
>>>> more a WeakArray but a simple Array.
>>>
>>> Yes, indeed, it is a normal Array and that cought my attention. But since
>>> I have no idea about Weak stuff...I also noticed that WeakOrderedCollection
>>> is declared as:
>>>
>>> OrderedCollection subclass: #WeakOrderedCollection
>>> instanceVariableNames: ''
>>> classVariableNames: ''
>>> poolDictionaries: ''
>>> category: 'Collections-Weak'
>>>
>>> instead of using the #weakSubclass: ... message:
>>>
>>> OrderedCollection weakSubclass: #WeakOrderedCollection
>>> instanceVariableNames: ''
>>> classVariableNames: ''
>>> poolDictionaries: ''
>>> category: 'Collections-Weak'
>>>
>>>
>>>>
>>>> This is because Pharo's WeakOrderedCollection is broken...
>>>>
>>>
>>> Do you know a weak collection that is not broken in Pharo and let me do a
>>> addLast: ?
>>>
>>>>
>>>> Every reference to Array from within OrderedCollection should be
>>>> replaced with message send (self arrayType).
>>>> See for example, OrderedCollection>>#grow
>>>>
>>>
>>> Thanks. I will check how many there are and try to fix them.
>>>
>>>>
>>>> Nicolas
>>>>
>>>> 2011/8/3 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>>>>> Hi guys. I am since yesterday trying to find something and I cannot. So
>>>>> at
>>>>> this point I need external eyes :)
>>>>> I have this little code:
>>>>>
>>>>> anObject := ClassWith2Var new.
>>>>> sharedObject := ClassWith1Var new.
>>>>> sharedObject var1: 'nose'.
>>>>> anObject var1: Date today.
>>>>> anObject var2: sharedObject.
>>>>>
>>>>> serializedObjects := FuelMareaSerializer new
>>>>> serializeAndWriteObject:
>>>>> anObject to: 'aFileName'.
>>>>> anObject := nil.
>>>>> sharedObject := nil.
>>>>>
>>>>> 3 timesRepeat: [Smalltalk garbageCollect].
>>>>> serializedObjects inspect.
>>>>>
>>>>>
>>>>>
>>>>> What is important here is that FuelMareaSerializer new
>>>>> serializeAndWriteObject: anObject to: 'aFileName' answers a
>>>>> WeakOrderedCollection with each object of the serialized graph (taking
>>>>> anObject as the root)
>>>>> Now, if I print the tempVar serializedObjects I see:
>>>>>
>>>>> a WeakOrderedCollection(ClassWith1Var ClassWith2Var Date DateAndTime
>>>>> Duration a ClassWith1Var a ClassWith2Var 3 August 2011
>>>>> 2011-08-03T00:00:00+02:00 0:02:00:00 1:00:00:00 86400 2455777 'nose' 0
>>>>> 7200)
>>>>>
>>>>> WHYYYY?? why are all there if I put a nil to both, anObject and
>>>>> sharedObejct. This WeakOrderedCollection should be with all nils
>>>>> (except
>>>>> classes). Why are not being garbage collected?
>>>>>
>>>>> If I explore, for example the tempVar sharedObejct, which is at
>>>>> serializedObjects at: 6 and then I put explore pointers I ONLY see
>>>>> the
>>>>> array of the WeakOrderedCollection pointing to it. I don't understand.
>>>>>
>>>>> Any help is really appreaciated.
>>>>>
>>>>> --
>>>>> Mariano
>>>>> http://marianopeck.wordpress.com
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>
Aug. 3, 2011
Re: [Pharo-project] Inspector limiting an object printString output
by Stéphane Ducasse
add a new entry :)
Stef
On Aug 3, 2011, at 6:10 AM, Igor Stasenko wrote:
> In
>
> Inspector>>selectionPrintString it uses:
>
> text := [self selection printStringLimitedTo: 5000]
>
> which sometimes not quite adequate (sometimes i need to display more).
>
> I think it would be nicer if inspector would ask object, if it desires
> to limit itself (when printing in big inspection pane)
> and what concrete limit it desires, instead of hardcoding the number
> in inspector.
>
> Something like:
>
> Object>>printStringLimited
> ^ self printLimit ifNotNil: [:limit |
> self printStringLimitedTo: limit ]
> ifNil: [
> self printString ].
>
> so, then #printLimit could be overridden by choice of developer, to
> set (or not) the limits
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
Aug. 3, 2011
Re: [Pharo-project] [squeak-dev] Re: Optimizing RunArray
by Stéphane Ducasse
Yes!
Since some months, I'm slowly learning the events and rewriting them.
I'm writing test and I hope that one of these days I will be able to have a nice event structure.
If you want to join or have a look
EventModel/EventModel on squeaksource.
The text stuff should benefit from that.
Stef
On Aug 3, 2011, at 1:01 AM, Nicolas Cellier wrote:
> One thing that super upset me is that TextEditor is still using the
> old selectors #readKeyboard #keyboard #keyboardPeek instead of using
> events.
> Look #handleInteraction:fromEvent:
> It still has this hackish code to transform event driven Morph into
> st-80-polling-ParagraphEditor-friendly-Sensor-like
> self editor sensor: (KeyboardBuffer new startingEvent: evt).
> IMO,
> self handleInteraction: [ editor readKeyboard ] fromEvent: evt.
> should be replaced with
> self handleInteraction: [ editor keyStroke: evt ].
> and the hack should be delegated to the TextMorphEditor (ParagraphEditor)
> keyStrocke: anEvent
> "Pass the event to a polling friendly sensor like so that old st-80
> code shall still work"
> self sensor: (KeyboardBuffer new startingEvent: evt).
> self readKeyboard.
> Then TextEditor>>keyStrocke: should dispatchKeyboardEvent: anEvent
> with: typeAhead and stop querying a pseudo sensor.
> Of course, that means changing a lot of methods in TextEditor (any
> method with 'sensor' in source).
> But if TextEditor is just a place holder for copying the st-80
> ParagraphEditor code and the early Morphic hacks, I just don't see the
> point of making such a copy ;)
>
> Nicolas
>
> 2011/8/2 Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com>:
>> I have tried again with huge text (my 45 MByte change log).
>> Main contributor seems to be Text composition.
>> A marginal gain (2 to 3% when resizing the window) is to remove the
>> indirection in TextStopConditions, and replace instance variable stops
>> with direct integer slots (variableSubclass)
>>
>> No guaranty the fileIn of attachment will work, modifying Text
>> processing is dangerous...
>>
>> Nicolas
>>
>> 2011/8/2 Stéphane Ducasse <stephane.ducasse(a)inria.fr>:
>>> Yes I was wondering about the same (for athens too :))
>>>
>>> Stef
>>>
>>> On Aug 2, 2011, at 2:16 PM, Igor Stasenko wrote:
>>>
>>>> Does it impacts the text rendering/processing speed?
>>>>
>>>>
>>>> On 2 August 2011 12:11, Nicolas Cellier
>>>> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>>> To complete myself, the fast #collect: already exists and is named
>>>>> #mapValues: except that it modifies the RunArray in place and also
>>>>> won't coalesce...
>>>>>
>>>>> I also gain a huge factor for #collect:as: be defining this method:
>>>>>
>>>>> RunArray>>fillFrom: aCollection with: aBlock
>>>>> "Evaluate aBlock with each of aCollections's elements as the argument.
>>>>> Collect the resulting values into self. Answer self."
>>>>> | newRuns newValues lastLength lastValue |
>>>>> newRuns := (Array new: aCollection size) writeStream.
>>>>> newValues := (Array new: aCollection size) writeStream.
>>>>> lastLength := 0.
>>>>> lastValue := Object new.
>>>>> aCollection do: [:each |
>>>>> | value |
>>>>> value := aBlock value: each.
>>>>> lastValue = value
>>>>> ifTrue: [lastLength := lastLength + 1]
>>>>> ifFalse:
>>>>> [lastLength > 0
>>>>> ifTrue:
>>>>> [newRuns nextPut: lastLength.
>>>>> newValues nextPut: lastValue].
>>>>> lastLength := 1.
>>>>> lastValue := value]].
>>>>> lastLength > 0
>>>>> ifTrue:
>>>>> [newRuns nextPut: lastLength.
>>>>> newValues nextPut: lastValue].
>>>>> self setRuns: newRuns contents setValues: newValues contents
>>>>>
>>>>> [ (Array new: 1000) collect: [:e | 4 atRandom] as: RunArray] bench.
>>>>> BEFORE: '25.1 per second.'
>>>>> AFTER: '1,080 per second.'
>>>>>
>>>>> It's worth a few lines of code.
>>>>>
>>>>> Nicolas
>>>>>
>>>>> 2011/8/2 Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com>:
>>>>>> I played a bit with RunArray, and found some un-optimized features.
>>>>>> First, I don't know why RunArray is an ArrayedCollection. It cannot
>>>>>> #add: but it can #addFirst: and #addLast:.
>>>>>> It cannot #add:withOccurrences: but it can #addLast:times:. Why
>>>>>> inventing new selectors for old behaviours ?
>>>>>> These operations will cost a realloc it the last value is different,
>>>>>> so the underlying runs/values could better be an OrderedCollection if
>>>>>> these operations are used often.
>>>>>> A RunArray cannot remove at all.
>>>>>> Very weird collection species, I don't like the implementation too much.
>>>>>>
>>>>>> Then, #do: loops could be far faster. They rely on ArrayedCollection
>>>>>> which inlines do: loops with #to:do: and #at:
>>>>>> But #at: is not that fast. Scanning the runs and counting elements
>>>>>> would result in a n^2 cost.
>>>>>> Fortunately there is a cache lastIndex,lastRun,lastOffset to keep a cost n.
>>>>>> Nonetheless, all the tests cost, and the loop is suboptimal.
>>>>>> Let use see:
>>>>>>
>>>>>> version 1:
>>>>>> RunArray>>fastDo: aBlock
>>>>>> runs with: values do: [:r :v |
>>>>>> r timesRepeat: [aBlock value: v]].
>>>>>>
>>>>>> | tmp |
>>>>>> tmp := ((Array new: 1000) collect: [:e | 4 atRandom]) as: RunArray.
>>>>>> {
>>>>>> [ tmp do: [:e |]] bench.
>>>>>> [ tmp fastDo: [:e |]] bench.
>>>>>> }
>>>>>> #('3,220 per second.' '6,290 per second.')
>>>>>>
>>>>>> But timesRepeat: is slow, it is unoptimized by the compiler and costs
>>>>>> a message send.
>>>>>> I think we should implement BlockClosure>>repeat: and optimize that
>>>>>> call in Compiler.
>>>>>> But let's not do it, and rather inline by ourself:
>>>>>>
>>>>>> version 2:
>>>>>> runs with: values do: [:r :v |
>>>>>> 1 to: r do: [:i | aBlock value: v]].
>>>>>>
>>>>>> | tmp |
>>>>>> tmp := ((Array new: 1000) collect: [:e | 4 atRandom]) as: RunArray.
>>>>>> {
>>>>>> [ tmp do: [:e |]] bench.
>>>>>> [ tmp do2: [:e |]] bench.
>>>>>> }
>>>>>> #('3,070 per second.' '25,500 per second.')
>>>>>>
>>>>>> We can even inline the with:do: loop itself:
>>>>>> version 3:
>>>>>> 1 to: runs size do: [:i |
>>>>>> | r v |
>>>>>> v := values at: i.
>>>>>> r := runs at: i.
>>>>>> [( r := r - 1) >= 0]
>>>>>> whileTrue: [aBlock value: v]].
>>>>>>
>>>>>> | tmp |
>>>>>> tmp := ((Array new: 1000) collect: [:e | 4 atRandom]) as: RunArray.
>>>>>> {
>>>>>> [ tmp do: [:e |]] bench.
>>>>>> [ tmp do2: [:e |]] bench.
>>>>>> }
>>>>>> #('3,370 per second.' '32,200 per second.')
>>>>>>
>>>>>> Now the operation I wanted to use was reverseDo: so I implemented:
>>>>>> RunArray>>fastReverseDo: aBlock
>>>>>> | i |
>>>>>> i := runs size.
>>>>>> [i > 0]
>>>>>> whileTrue:
>>>>>> [ | r v |
>>>>>> v := values at: i.
>>>>>> r := runs at: i.
>>>>>> i := i - 1.
>>>>>> [( r := r - 1) >= 0]
>>>>>> whileTrue: [aBlock value: v]].
>>>>>> | tmp |
>>>>>> tmp := ((Array new: 1000) collect: [:e | 4 atRandom]) as: RunArray.
>>>>>> {
>>>>>> [ tmp reverseDo: [:e |]] bench.
>>>>>> [ tmp reverseDo2: [:e |]] bench.
>>>>>> }
>>>>>> #('83.9 per second.' '32,600 per second.')
>>>>>>
>>>>>> Ouch! The cache is missing a lot of indices, and our loop turns into a n^2 cost.
>>>>>> I know, premature optimization bla bla bla, but a factor x400 is worth
>>>>>> some inlining no?
>>>>>>
>>>>>> I guess these features are never used.
>>>>>> By now RunArray is kind of private utility for Text implementation.
>>>>>> But it could / should be generic.
>>>>>>
>>>>>> I also have proposals for count: / select: / collect:. etc...
>>>>>> It would be to evaluate the block only once per group of values.
>>>>>> For example
>>>>>> RunArray>>collect: aBlock
>>>>>> "Beware, the block will be evaluated only once per group of values."
>>>>>> ^(self class runs: (runs collect: aBlock) contents values: values
>>>>>> copy) coalesce
>>>>>> But that's controversial, it would make the RunArray behave
>>>>>> differently if the block has side effects...
>>>>>>
>>>>>> | i tmp tmp2 tmp3 |
>>>>>> tmp := ((Array new: 1000) collect: [:e | 4 atRandom]).
>>>>>> i := 0.
>>>>>> tmp2 := tmp collect: [:e | i := i + 1].
>>>>>> i := 0.
>>>>>> tmp3 := (tmp as: RunArray) collect: [:e | i := i + 1].
>>>>>> tmp2 = tmp3 asArray
>>>>>> ==> false
>>>>>>
>>>>>> Nicolas
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best regards,
>>>> Igor Stasenko AKA sig.
>>>>
>>>
>>>
>>>
>>
>
Aug. 3, 2011