Dear root expert,
I have a very simple test job, copy the tree from an old file to
a new file event by event.
The old tree have more then 30000 events and more than
1000 branches, the original size is 800M, the jobs crashed at the end
when it write and save the new file, it look like is due to the memory
problems. The error message is :
terminate called after throwing an instance of 'std::bad_alloc’
what(): St9bad_alloc
My machine is 4 core with 8G memory.
When I run for 10000 events, the jobs is successful, but when I load
the tree, and print it, I found that the speed of print the new tree is much
slower than the speed of loading old tree, the compressions of tree and
branch are different between new and old tree, also in each branch, the new
tree show " All baskets in memory". How can I fix the problems.
I attach the print messages and my code
Old tree :
*Tree :CollectionTree: CollectionTree *
*Entries : 36588 : Total = 2508577943 bytes File Size = 832988990 *
-
: : Tree compression factor = 3.01 *
*Br 0 :RunNumber : RunNumber/I *
*Entries : 36588 : Total Size= 147382 bytes File Size = 1120 *
*Baskets : 4 : Basket Size= 32000 bytes Compression= 114.28 *
…
*Br 1 :EventNumber : EventNumber/I *
*Entries : 36588 : Total Size= 147402 bytes File Size = 46517 *
*Baskets : 4 : Basket Size= 32000 bytes Compression= 2.75 *
…
*Br 2 :StreamESD_ref : StreamESD_ref/C *
*Entries : 36588 : Total Size= 5767282 bytes File Size = 434011 *
new Tree :
*Tree :CollectionTree: CollectionTree *
*Entries : 10000 : Total = 519198944 bytes File Size = 191956168 *
-
: : Tree compression factor = 1.00 *
*Br 0 :RunNumber : RunNumber/I *
*Entries : 10000 : Total Size= 40850 bytes All baskets in memory *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
…
*Br 1 :EventNumber : EventNumber/I *
*Entries : 10000 : Total Size= 40866 bytes All baskets in memory *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
…
*Br 2 :StreamESD_ref : StreamESD_ref/C *
*Entries : 10000 : Total Size= 1581118 bytes All baskets in memory *
*Baskets : 50 : Basket Size= 32000 bytes Compression= 1.00 *
…
My code :
void test2() {
TBenchmark* Mybench = new TBenchmark();
Mybench->Start(“Analysis time”);
TChain *fchain = new TChain(“CollectionTree”);
fchain->Add(“user09.JoaquinPovedaTorres.0108173.topmix_Egamma.AANT.AANT._00001.root.1”);
TTree *ntuple = NULL;
int index =0;
char buffer[40];
cout<<" entry = “<GetEntries()<<endl;
ntuple = fchain->CloneTree(0);
ntuple->SetDirectory(0);
fchain->CopyAddresses(ntuple);
for(int i=0; iGetEntries()&&i<10000; i++){
if(i%2000==0)cout<<” i = "<<i<<endl;
fchain->GetEntry(i);
ntuple->Fill();
ntuple->AutoSave();
}
TFile *f = new TFile(“test.root”,“recreate”);
ntuple->Write();
ntuple->Delete();
f->Write();
f->Close();
Mybench->Stop(“Analysis time”);
Mybench->Show(“Analysis time”);
}
thanks in advance.
with best regards
—Haiping