performance improvements with atlas aod files

22
Performance Improvements with ATLAS AOD files Rene Brun 3 November 2009

Upload: aislin

Post on 23-Mar-2016

44 views

Category:

Documents


1 download

DESCRIPTION

Performance Improvements with ATLAS AOD files. Rene Brun 3 November 2009. Main Points. Typical problems with Trees Branch buffers not clustered by entry Forward/backward seeks when reading Too many network transactions Expensive object model ( cpu time) Solutions TTreeCache - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Performance Improvements with ATLAS AOD files

Performance Improvements

with ATLAS AOD filesRene Brun

3 November 2009

Page 2: Performance Improvements with ATLAS AOD files

Main PointsTypical problems with Trees

Branch buffers not clustered by entryForward/backward seeks when readingToo many network transactionsExpensive object model (cpu time)

SolutionsTTreeCacheReadahead bufferReclustering online or a-posteriori with TTree::OptimizeBasketsCheaper object modelMonitoring with TTreePerfStats

Page 3: Performance Improvements with ATLAS AOD files

See Doctor

Too many reads

Small blocks

Page 4: Performance Improvements with ATLAS AOD files

Use TTreePerfStats

void taodr(Int_t cachesize=10000000) { gSystem->Load("aod/aod"); //shared lib generated with TFile::MakeProject TFile *f = TFile::Open("AOD.067184.big.pool.root"); TTree *T = (TTree*)f->Get("CollectionTree"); Long64_t nentries = T->GetEntries(); T->SetCacheSize(cachesize); if (cachesize > 0) { T->SetCacheEntryRange(0,nentries); T->AddBranchToCache("*",kTRUE); } TTreePerfStats ps("ioperf",T); for (Long64_t i=0;i<nentries;i++) { T->GetEntry(i); } ps.SaveAs("aodperf.root"); ps.Draw(); ps.Print();}

Root > TFile f(“aodperf.root”)Root > ioperf.Draw()

Page 5: Performance Improvements with ATLAS AOD files

Test conditionsBecause both the TreeCache and Readahead are designed to minimize the difference RealTime-CpuTime, care has been taken to run the tests with “cold” files, making sure that system buffers were dropped before running a new test.

Note that increasing the TreeCache size reduces also the CpuTime.

Note that running OptimizeBaskets also reduces substantially the CpuTime because the number of baskets is in general reduced by several factors.

Page 6: Performance Improvements with ATLAS AOD files

Test conditions 2Using one of the AOD files the class headers have been generated automatically via TTree::MakeProject.

The corresponding shared library is linked such that the same object model is used in my tests and in Atlas persistent model.

The tests read systematically all entries in all branches. Separate tests have been run to check that the optimal performance is still obtained when reading either a subset of branches, a subset of entries or both. This is an important remark because we have seen that sometimes proposed solutions are good when reading everything and very bad in the other mentioned use cases that are typical of the physics analysis scenarios.

Page 7: Performance Improvements with ATLAS AOD files

What is the TreeCache

It groups into one buffer all blocks from the used branches.

The blocks are sorted in ascending order and consecutive blocks merged such that the file is read sequentially.

It reduces typically by a factor 1000 the number of transactions with the disk and in particular the network with servers like xrootd or dCache.

The small blocks in the buffer can be unzipped in parallel on a multi-core machine.

The typical size of the TreeCache is 10 Mbytes, but higher values will always give better results. If you have no memory problem, set large values like 200 Mbytes.

Page 8: Performance Improvements with ATLAS AOD files

TreeCache size impact

0

200

10

30

Page 9: Performance Improvements with ATLAS AOD files

File with 203 branches and split=0

TreeCache is an overhead

In case of a local diskIt is essential with

xrootd

Page 10: Performance Improvements with ATLAS AOD files

Similar pattern with CMS files

Page 11: Performance Improvements with ATLAS AOD files

TreeCache results graph

Page 12: Performance Improvements with ATLAS AOD files

TreeCache results table

Cache size (MB)

readcalls RT pcbrun4 (s)

CP pcbrun4 (s)

RT macbrun (s)

CP macbrun (s)

0 1328586 734.6 270.5 618.6 169.8LAN 1ms 0 1328586 734.6+1300 270.5 618.6+1300 169.8

10 24842 298.5 228.5 229.7 130.130 13885 272.1 215.9 183.0 126.9

200 6211 217.2 191.5 149.8 125.4

Cache size (MB)

readcalls RT pcbrun4 (s)

CP pcbrun4 (s)

RT macbrun (s)

CP macbrun (s)

0 15869 148.1 141.4 81.6 80.7LAN 1ms 0 15869 148.1 + 16 141.4 81.6 + 16 80.7

10 714 157.9 142.4 93.4 82.530 600 165.7 148.8 97.0 82.5

200 552 154.0 137.6 98.1 82.0

Cache size (MB)

readcalls RT pcbrun4 (s)

CP pcbrun4 (s)

RT macbrun (s)

CP macbrun (s)

0 515350 381.8 216.3 326.2 127.0LAN 1ms 0 515350 381.8 + 515 216.3 326.2 +515 127.0

10 15595 234.0 185.6 175.0 106.230 8717 216.5 182.6 144.4 104.5

200 2096 182.5 163.3 122.3 103.4

Reclust: OptimizeBaskets 30 MB (1086 MB), 9705 branches split=99

Reclust: OptimizeBaskets 30 MB (1147 MB), 203 branches split=0

Original Atlas file (1266MB), 9705 branches split=99

Page 13: Performance Improvements with ATLAS AOD files

What is the readahead cache

The readahead cache will read all non consecutive blocks that are in the range of the cache.

It minimizes the number of disk accesses. This operation could in principle be done by the OS, but the fact is that the OS parameters are not tuned for many small reads, in particular when many jobs read concurrently from the same disk.

When using large values for the TreeCache or when the baskets are well sorted by entry, the readahead cache is not necessary.

Typical (default value) is 256 Kbytes, although 2 Mbytes seems to give better results on Atlas files, but not with CMS or Alice.

The readahead cache should not be used in several use cases (see 2 examples later)

Page 14: Performance Improvements with ATLAS AOD files

Readahead reading all branches, all

entries

Read aheadexcellent

Page 15: Performance Improvements with ATLAS AOD files

Reading only 2 branches

out of 9705 Read aheadvery bad

Page 16: Performance Improvements with ATLAS AOD files

Reading all branches in 1% random entries

Read aheadvery bad

TreeCache is bad

If it is not usedwith a

TEntryList

Page 17: Performance Improvements with ATLAS AOD files

comments

It is not because we get this pattern that the TreeCache or readahead should be used in all cases.

The control must be on the application side.

Ideally one should be able to activate/deactivate the readahead automatically (working on this)

Hints could be generated automatically following the results collected by TTreePerfStats (requires more work)

Page 18: Performance Improvements with ATLAS AOD files

Comments 2These tests have been done with files on a local disk.

In case of client-server mode with xrootd, dCache or httpd, the TreeCache is vital.

Using the TreeCache, ROOT can read efficiently files on WANs with very high latencies.

The readahead algorithm is currently implemented only for TFile. It could be implemented in the xrootd and dCache servers too.

Page 19: Performance Improvements with ATLAS AOD files

Comments 3I have discussed only techniques improving the RealTime. Don’t forget other optimizations improving the CpuTime

Minimize inheritance levels with split=0Do not abuse of std::string or similar small objects that contribute to the memory fragmentation.Use std::vector<T*> in situations where the Ts derive from a common class. This is better than increasing the number of branches.TClonesArray is still the most performing collection of identical objects (see test program bench)

Page 20: Performance Improvements with ATLAS AOD files

Comments 4ROOT version 5.25/02 includes a new and simpler API to the TreeCache.

It also includes the new readahead algorithm.

Xrootd in this version contains several new developments and optimisations.

These new features CANNOT be backported to 5.24 or worst to 5.22.

5.25/02 and the coming 5.26 are back compatible with 5.22. We expect collaborations to move to this new version.

Page 21: Performance Improvements with ATLAS AOD files

Comments 5I am convinced that OptimizeBaskets, TreeCache and Readahead algorithms can be further improved.

We need the cooperation of the experiments, testing many more use cases and giving feedback (eg sending the results of TTreePerfStats file.

Do not keep the results of your test under the carpet. Our priority is to help the experiments improving the situation .

Page 22: Performance Improvements with ATLAS AOD files

Situation with CMS

mail from Brian Bocklelmann (today)- OptimizeBaskets did see an improvement in reads of the resulting file. The strange "tails" that you see in the plots I sent out become less pronounced (although definitely do not disappear)- Paul and Philippe are now convinced that there are no re-reads in the TTreeCache.- TTreeCache with 20MB seems to be sufficiently large; covers about 2500 events- Readahead implemented in ReadBuffers is effective; a smaller size of 64KB provides a marked speed increase over 256KB readahead. Depending on the bandwidth of the data channel, the over-read percentage in the 256KB readahead case can become significant

One thing that I've learned tonight is that the readv interface in dCache is not well-implemented (on the server side, it's a for-loop over calls to read) and that you can get speed increases by removing TDcacheFile's implementation of ReadBuffers.

I believe that, after 2 days of working with Philippe, the current set of recommendations is:1) Apply the remaining fix to make TTreeCache work in CMSSW, enable it wherever possible, and set it to around 20-30MB2) Utilize ROOT's implementation of ReadBuffers3) When we migrate to ROOT 5.26, enable calls to OptimizeBaskets when writing out initial files (as it has no effect for fast merging).4) Remove TDcacheFile's implementation of ReadBuffers *or* implement the optimization equivalent to ROOT's in the dCache server code.

I believe 1, 2, and 4 are relatively easy.