[Vm-dev] Re: A trick to speedup #become: (but not becomeForward:)
siguctua at gmail.com
Sun Jul 31 15:06:41 UTC 2011
On 31 July 2011 10:32, Andreas Raab <andreas.raab at gmx.de> wrote:
> On 7/31/2011 6:56, Igor Stasenko wrote:
>> And it works! All become tests are green.
>> See attached for VM and image side code.
> Good idea. But your benchmark is a little off:
>> Now most interesting thing. How much speed we gain?
>> | x y |
>> x := 'ab' copy.
>> y := 'cd' copy.
>> [ 100 timesRepeat: [ x become: y ] ] timeToRun
> x and y should be young in the above and the performance of #become should
> be much faster than when they are old. To wit:
> [ 100 timesRepeat: [ 'ab' copy become: 'cd' copy ] ] timeToRun
> => 36
> | x y |
> x := 'ab' copy.
> y := 'cd' copy.
> Smalltalk garbageCollect. "make x and y old"
> [ 100 timesRepeat: [ x become: y ] ] timeToRun
> => 1248
> So I'm not sure how valid your benchmark really is.
It is valid, because i comparing performance of using same method (#become:)
before and after changes.
But of course, a heap-scanning become heavily depends where object(s)
located in young space or old one,
and performs much faster if it needs to scan only new space.
But memory-swapping become apparently having no such dependency. It
only depends on object size to be swapped.
So, okay.. for cases, when both objects residing in new space, it will
be not hundrends of thousands times faster but only tens thousands
Which is still a huge advantage.
> - Andreas
Igor Stasenko AKA sig.
More information about the Vm-dev