Array new: 1000000 performance question

John M McIntosh johnmci at smalltalkconsulting.com
Tue Jul 20 18:29:52 UTC 2004


Once the array is in NewSpace we iterate over all 1,000,000 elements on  
a newspace GC event to mark/trace the elements.
This iteration of a million items does take time. This happens on every  
newspace GC event, so as you notice CPU usage goes up.

The Smalltalk garbageCollect forces a tenure of the survivors in  
newspace to OldSpace by compacting the objects and
moving the newspace pointer to the end of allocated memory. This drops  
the large array from the scope of the newspace GC event, it's
tenured and becomes an old object.

You'll note if you allocate a new object then drop it into the Array  
then it will cause the million array object to become a root object  
since
it points to an element in newspace. This causes us to iterate over the  
million elements again and CPU time will go way up.

Solving this issue is an exercise for the reader.

On Jul 19, 2004, at 7:11 PM, Jack Keel wrote:

> Hi,
>
> Sorry if this is a known issue.
>
> I discovered a curious performance issue in Squeak (3.7 and 3.6, Mac  
> and Windows):
>
> Squeak idling cpu use (2% on 3Ghz XP and 9% on 350 Mhz G3)
> then do it:
> t := Array new: 1000000.
>
> Array allocation is quick but cpu usage jumps to 15% (XP) 35%(on G3)  
> and stays there.
> Tried it in VW 7.2 and it didn't do this.
> Using new: 1000 didn't trigger the cpu use either.
>
> Smalltalk garbageCollect.  "Fixes it even though the object is still  
> instantiated"
>
> What causes this?
>
> Jack
>
>
>
>
--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list