Re: TFile effectivity

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 10 Nov 2009 15:57:43 +0100


Jakub Čermák wrote:
> Thanks. Just to be sure - after calling TFile::WriteTObject() I can delete the original object from memory, right? But copy of it still resides in TFile's cache (in RAM memory), or it's written to disk immediately (disregarding OS cache)? If 1st is true, can I force moving the histogram content from memory to disk e.g. with TFile::Flush()?
>

As soon as you have written your object to the file, you can delete it from memory. The object is not kept
in a TFile cache. You do not need to call TFile::Flush unless you suspect that your application may crash
during execution, but even in this case, it is likely that ROOT will be able to recover your object.
> Why TTree has O(1) random access or write? All balanced trees have O(log n) random access and write. Or is it some other structure?
>

ROOT Trees do not use the technique of balanced trees (totally inappropriate in this case).
ROOT TTree tables are such that the position of an entry in the Tree is performed by looking into compact direct access tables in memory. see the TTree documentation and its pictures.

Rene Brun
> S pozdravem / Best regards
>
> Jakub Čermák
> http://www.jcermak.cz
>
>
>
>> -----Original Message-----
>> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
>> On Behalf Of Rene Brun
>> Sent: Saturday, November 07, 2009 7:49 AM
>> To: Jakub Čermák
>> Cc: roottalk_at_cern.ch
>> Subject: Re: [ROOT] TFile effectivity
>>
>> The only thing that TFile keeps in memory is the TKey object (less than
>> 100 bytes depending the length of the object name).
>> Once you have written your object (histogram) to the file, you can
>> delete it from memory.
>> You should be able to store millions of objects on the file.
>> Note, however, than when you have a very large number of objects to
>> write, it is better to
>> create a TTtree, where the only object per entry can be a histogram.
>> The access time to each object will be faster (direct access) instead
>> of
>> a log(n) behavior when
>> writing them one by one as you do.
>>
>> Rene Brun
>>
>> Jakub Čermák wrote:
>>
>>> Hello *,
>>> I'm writing an app which makes large number of histograms and some
>>>
>> other graphs and then writes them to TFile. I'd like to avoid holding
>> all the objects in memory, because they can be safely written to the
>> file and discarded. I destruct all of them as soon as I don't need
>> them, but I suppose TFile holds them somewhere in its cache. So the
>> question is - is it possible to write a bunch of root objects into a
>> file and discard them from memory? So the new histograms will be
>> appended at disk to already written ones without need to hold them all
>> in memory. I found a Flush function, but I don't know whether it's what
>> I need.
>>
>>> Thanks
>>>
>>> Best regards
>>>
>>> Jakub Čermák
>>> http://www.jcermak.cz
>>>
>>>
>>>
>>>
>
>
>
Received on Tue Nov 10 2009 - 15:57:31 CET

This archive was generated by hypermail 2.2.0 : Wed Nov 11 2009 - 17:50:03 CET