Re: benchmarking TClonesArray vs STL vector

From: Chris Green (greenc@fnal.gov)
Date: Wed Dec 16 1998 - 03:36:25 MET


On Tue, 15 Dec 1998, Pasha Murat wrote:

> 
> Hi Rooters,
> 
> 	I finally found some time to benchmark ROOT TClonesArray against
> STL vectors. Briefly the results: for HEP-like applications (loop over
> the events) TClonesArray seems to be more efficient than STL vectors
> even if no sorting of the objects is involved.  On SGI IRIX6.2
> (R10000) the test code using TClonesArray runs about 50% faster than
> similar code using STL vector of objects and about 3 times faster than
> the code using STL vector of pointers.
> 
> 	The results on Linux are similar, those are preliminary though.
> 
> While satisfied, I do not quite understand why TClonesArray performed
> in this test faster than vector. It is also clear that when the
> sorting will be involved the difference should become even more
> striking. May be there is something in my code I don't see?

Hi, Pasha.

I'm sure Rene will fill in the blanks and correct me when I'm wrong, but I
had a chat with an expert (Jim Kowalkowski) about this, and he pointed out
the following: the main reason TClonesArray is faster is because of the
fact that Rene has redone the memory allocation, so that it is done in
chunks rather than per object, and the memory is recycled. The facility
exists in STL, too -- all (I think) the containers allow you to specify an
allocator which is used to allocate the memory. The default is the one we
all know and love, but when extreme speed is needed for particular
applications, it is common to custom-write one's own allocator. It would
be interesting to see how an STL vector would perform in your test were
one to write an allocator using the same algorithm as the TClonesArray. To
first order, I'm guessing the two would be identical.

As you and I have discussed privately though, more worrying is the fact
that problems occur when using ROOT code which has been compiled
optimised: that puts a serious limitation on execution speed right from
the beginning, and mitigates against using ROOT as it is right now in
applications where speed is critical.

Cheers,
Chris.

> 
> See the description of the test conditions and the complete source code of the program 
> executed (including the Makefile) at URL
> 
> http://www-cdf.fnal.gov/upgrades/computing/projects/run2mc/run2mc.html
> 
> (see news from Dec 14, this includes a little bit of advertisement of new CDF MC web page), 
> 
> a direct pointer is:
> 
> http://www-cdf.fnal.gov/upgrades/computing/projects/run2mc/minutes/1998_12_10/TClonesArray_vs_vector.html
> 
> 			I appreciate any comments, regards, pasha.
> 

--
Chris Green. HEP, Purdue University. CDF SVXII project. 
Based at Fermilab. MAIL greenc@fnal.gov; PHONE (630) 840-2308



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:41 MET