How to call TTree::SetAutoFlush()?

Dear ROOTers,

The help file in the source code TTree.cxx contains the following statement:

void TTree::SetAutoFlush(Long64_t autof)
{
   // This function may be called at the start of a program to change
   // the default value for fAutoFlush.
}

However, while I can do the following at the start of my program:

   TTree::SetMaxTreeSize(10000000);

since TTree::SetMaxTreeSize() is a static function, this is not possible for TTree::SetAutoFlush().

Thus how can I change the default value for fAutoFlush at the start of my program for all trees?

Best regards
Christian

There is currently no interface to set a global value for the AutoFlush parameter. The main reason is that is does not make much sense.
I suggest to read carefully the documentation of TTree::SetAutoFlush,
the documentation of TTreeCache and also the 5.26 release notes.
Ideally an application should have only one output Tree at any given time.
The default value for AutoFlush has been tuned to a reasonable value
for any reasonable Tree organization.

Rene

Dear Rene,

Sorry for the late reply but it took me a very long time to work things out.

Initially I wanted to set “tree->SetAutoFlush(0)” to disable the AutoFlush mechanism, however it turns out that
the problem with “tree->DropBaskets()” is not related to filling trees but to reading trees. Today I have finally
succeeded and it seems that the new implementations in TTree and/or TBranch are not compatible with ROOT files
created with earlier versions of ROOT when using DropBaskets(). For details see the topic on DropBaskets():
root.cern.ch/phpBB2/viewtopic.ph … 4883#42168

Maybe one more issue: Since earlier versions of ROOT do not have a method TTree::SetAutoFlush(), in my opinion it
would be better if the default value would be “tree->SetAutoFlush(0)”.

Best regards
Christian

Christian,

Philippe will investigate your problem with DropBaskets (personally I do not understand why you had to call this function, probably a consequence of your bad organization with too many Trees).
Concerning SetAutoFlush: If you read a file produced with versions <5.26, by definition the information of AutoFlush is not in the file, hence no performance improvement in this case. It is identical to a file produced and read with 5.26 and AutoFlush set to 0.
Of, course, we do not want to set autoflush to 0 by default. The default new AutoFlush provides a very substantial performance improvment when reading trees (we have seen up to a factor 10) when reading files generated with 5.26.

Rene

Dear Rene,

I understand that ROOT is optimized for HEP, and maybe there the best way is to use one tree only. However, as
you know I am using it for DNAChip experiments and thus create one tree per DNAChip. It does not make sense to
create only one tree and have one branch per experiment, since users tend to add DNAChips later. Furthermore,
they may want to analyze separate experiments together, thus they would need to combine trees for these different
experiments, anyhow. Of course, it would be possible to force users to import the DNAChip data any time they want
to mix different data, but I consider this to be user unfriendly.

Usually, experiments consist of at most few hundred DNAChips (often less than hundred), and for these cases my
program works w/o any memory problem. There was only one user who downloaded all about 23,000 publically available
data, and wanted to analyze them together, which is pretty unusual for a number of reasons. However, even he reported
that for up to 2000 trees my program did not show increased memory usage, but then memory usage did increase. I hope
that you understand that I want to handle my program also this extreme case w/o memory problems. Thus, with the help
of Philippe I made the necessary changes so that now even in this extreme case about 2-3GB RAM are enough.

Regarding SetAutoFlush() I understand that you do not want to set autoflush to 0 by default, and from your answer
I understand that this seems not to be necessary.

Best regards
Christian