Little challenge

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

Little challenge

ducasse

Hi

I would like know how many instances of Color are instantiated by a theme.
I would like to know how many times the same color is created.

I’m creating a theme using a dictionary instead of stupidly returning color.
May be like that I can use an LRUCache to see the number of hits.

I will see if I can instrument Color new.

We really need tools that help us measuring things.

Any other ideas?

S.


Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

ducasse
Color >> basicNew
        Transcript show: '.'; cr.
        ^ super basicNew


This is scary.
I will save in a file because we are creating so many spurious colors that it is nearly not possible to see the amount.


Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

ducasse
So now I know how many instance of colors are created when we switch theme and it looks like a real plague.
I will let you guess the number but this is not a small one :(

I will check on my lovely theme if using a dictionary can manage it.

> On 8 Jan 2020, at 21:51, ducasse <[hidden email]> wrote:
>
> Color >> basicNew
> Transcript show: '.'; cr.
> ^ super basicNew
>
>
> This is scary.
> I will save in a file because we are creating so many spurious colors that it is nearly not possible to see the amount.
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Esteban A. Maringolo
I'll make the first guess: 10^6 calls.

Esteban A. Maringolo

On Wed, Jan 8, 2020 at 6:03 PM ducasse <[hidden email]> wrote:

>
> So now I know how many instance of colors are created when we switch theme and it looks like a real plague.
> I will let you guess the number but this is not a small one :(
>
> I will check on my lovely theme if using a dictionary can manage it.
>
> > On 8 Jan 2020, at 21:51, ducasse <[hidden email]> wrote:
> >
> > Color >> basicNew
> >       Transcript show: '.'; cr.
> >       ^ super basicNew
> >
> >
> > This is scary.
> > I will save in a file because we are creating so many spurious colors that it is nearly not possible to see the amount.
> >
> >
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

ducasse
luckily not :)


> On 8 Jan 2020, at 22:07, Esteban Maringolo <[hidden email]> wrote:
>
> I'll make the first guess: 10^6 calls.
>
> Esteban A. Maringolo
>
> On Wed, Jan 8, 2020 at 6:03 PM ducasse <[hidden email]> wrote:
>>
>> So now I know how many instance of colors are created when we switch theme and it looks like a real plague.
>> I will let you guess the number but this is not a small one :(
>>
>> I will check on my lovely theme if using a dictionary can manage it.
>>
>>> On 8 Jan 2020, at 21:51, ducasse <[hidden email]> wrote:
>>>
>>> Color >> basicNew
>>>      Transcript show: '.'; cr.
>>>      ^ super basicNew
>>>
>>>
>>> This is scary.
>>> I will save in a file because we are creating so many spurious colors that it is nearly not possible to see the amount.
>>>
>>>
>>
>>
>>
>



Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Pharo Smalltalk Developers mailing list
In reply to this post by ducasse
You are very right. Unfortunately, there are many situation like this. Consider:

Point allInstances size "101283"
Point allInstances asSet size "11381"

'String' class allInstances size "111492"
'String' class allInstances asSet size “57874"

A lot of duplication around…

Cheers,
Alexandre


> On 08-01-2020, at 21:42, ducasse <[hidden email]> wrote:
>
>
> Hi
>
> I would like know how many instances of Color are instantiated by a theme.
> I would like to know how many times the same color is created.
>
> I’m creating a theme using a dictionary instead of stupidly returning color.
> May be like that I can use an LRUCache to see the number of hits.
>
> I will see if I can instrument Color new.
>
> We really need tools that help us measuring things.
>
> Any other ideas?
>
> S.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Sean P. DeNigris
Administrator
In reply to this post by ducasse
ducasse wrote
> it looks like a real plague.

What is the real effect on performance? There is a cost to the complexity of
e.g. caching too, no?



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Esteban A. Maringolo
Well... the theme having these colors in a table of some sort, even
keyed by a role name (very much like windows), isn't like a lot of
work.

Of course, "premature optimization is the root of all evil". But given
that such "careless" behavior has been around for a while, maybe it is
not premature any longer. :)

Regards!

Esteban A. Maringolo

On Thu, Jan 9, 2020 at 5:14 PM Sean P. DeNigris <[hidden email]> wrote:

>
> ducasse wrote
> > it looks like a real plague.
>
> What is the real effect on performance? There is a cost to the complexity of
> e.g. caching too, no?
>
>
>
> -----
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
>

Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Sven Van Caekenberghe-2
Another requirement for caching and sharing instances is that the object is a true read only value object.

> On 9 Jan 2020, at 22:45, Esteban Maringolo <[hidden email]> wrote:
>
> Well... the theme having these colors in a table of some sort, even
> keyed by a role name (very much like windows), isn't like a lot of
> work.
>
> Of course, "premature optimization is the root of all evil". But given
> that such "careless" behavior has been around for a while, maybe it is
> not premature any longer. :)
>
> Regards!
>
> Esteban A. Maringolo
>
> On Thu, Jan 9, 2020 at 5:14 PM Sean P. DeNigris <[hidden email]> wrote:
>>
>> ducasse wrote
>>> it looks like a real plague.
>>
>> What is the real effect on performance? There is a cost to the complexity of
>> e.g. caching too, no?
>>
>>
>>
>> -----
>> Cheers,
>> Sean
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

Alejandro Infante
The profiler of my master thesis does this (and a lot more). It instruments new on all classes in a package + some other core things like String, Color, Rectangle and Collections and check if some of them have equivalent state and are immutable. If they are the profiler allows you to group the instances by the context where you allocated them (a simple stack trace, nothing fancy).


It doesn’t have a cool ui, but it works :)

Alejandro

On Jan 9, 2020, at 7:17 PM, Sven Van Caekenberghe <[hidden email]> wrote:

Another requirement for caching and sharing instances is that the object is a true read only value object.

On 9 Jan 2020, at 22:45, Esteban Maringolo <[hidden email]> wrote:

Well... the theme having these colors in a table of some sort, even
keyed by a role name (very much like windows), isn't like a lot of
work.

Of course, "premature optimization is the root of all evil". But given
that such "careless" behavior has been around for a while, maybe it is
not premature any longer. :)

Regards!

Esteban A. Maringolo

On Thu, Jan 9, 2020 at 5:14 PM Sean P. DeNigris <[hidden email]> wrote:

ducasse wrote
it looks like a real plague.

What is the real effect on performance? There is a cost to the complexity of
e.g. caching too, no?



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html





Reply | Threaded
Open this post in threaded view
|

Re: Little challenge

ducasse
Hello alejandro 

Thanks for the reminder. 
I will have a look. 

S

On 10 Jan 2020, at 12:26, Alejandro Infante <[hidden email]> wrote:

The profiler of my master thesis does this (and a lot more). It instruments new on all classes in a package + some other core things like String, Color, Rectangle and Collections and check if some of them have equivalent state and are immutable. If they are the profiler allows you to group the instances by the context where you allocated them (a simple stack trace, nothing fancy).


It doesn’t have a cool ui, but it works :)

Alejandro

On Jan 9, 2020, at 7:17 PM, Sven Van Caekenberghe <[hidden email]> wrote:

Another requirement for caching and sharing instances is that the object is a true read only value object.

On 9 Jan 2020, at 22:45, Esteban Maringolo <[hidden email]> wrote:

Well... the theme having these colors in a table of some sort, even
keyed by a role name (very much like windows), isn't like a lot of
work.

Of course, "premature optimization is the root of all evil". But given
that such "careless" behavior has been around for a while, maybe it is
not premature any longer. :)

Regards!

Esteban A. Maringolo

On Thu, Jan 9, 2020 at 5:14 PM Sean P. DeNigris <[hidden email]> wrote:

ducasse wrote
it looks like a real plague.

What is the real effect on performance? There is a cost to the complexity of
e.g. caching too, no?



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html