# SetTitle slows down RDataFrame performance

**URL:** <https://root-forum.cern.ch/t/settitle-slows-down-rdataframe-performance/41627>\
**Category:** Newbie\
**Tags:** rdataframe\
**Created:** [September 28, 2020, 11:49am UTC](https://root-forum.cern.ch/t/settitle-slows-down-rdataframe-performance/41627 "2020-09-28T11:49:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tancredi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tancredi/32/20395_2.png) [@tancredi](https://root-forum.cern.ch/u/tancredi)\
**Post date:** [September 28, 2020, 11:49am UTC](https://root-forum.cern.ch/t/settitle-slows-down-rdataframe-performance/41627/1 "2020-09-28T11:49:24Z")

</div>

Hello,

this is probably a feature, but I run into something rather natural for data analysis that slows downs the RDataFrame performance. I attach a test program based on an existing tutorial.

The timing performance is good and behaves as expected with the default program:

```auto
Histo1D photon_eta 0.174297094345 [sec]
Histo1D photon_pt 0.00482892990112 [sec]
Histo1D photon_E 0.00204801559448 [sec]
Histo1D photon_ptcone30 0.0020010471344 [sec]
Draw photon_eta 26.5902540684 [sec]
Draw photon_pt 2.00271606445e-05 [sec]
Draw photon_E 5.00679016113e-06 [sec]
Draw photon_ptcone30 3.09944152832e-06 [sec]

```

However, if I turn on the line

```auto
varhistos[myvar].GetXaxis().SetTitle(myvar); 

```

just after defining the histogram model, it seems that RDataFrame loops for each histogram over the tree

```auto
Histo1D photon_eta 9.44745612144 [sec]
Histo1D photon_pt 9.23581314087 [sec]
Histo1D photon_E 11.1579310894 [sec]
Histo1D photon_ptcone30 13.5817921162 [sec]
Draw photon_eta 0.0102381706238 [sec]
Draw photon_pt 1.09672546387e-05 [sec]
Draw photon_E 2.86102294922e-06 [sec]
Draw photon_ptcone30 3.09944152832e-06 [sec]
>>> 

```

Naively I find surprising that setting a title in the histo model has such an effect.

May be a good warning for others.[test4.py](https://root-forum.cern.ch/uploads/short-url/4orYQbCM5uJ8fE1Jm5cQsQYRmHS.py) (919 Bytes)

Regards,

Tancredi

* * *

_ROOT Version:_ /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.02/x86\_64-centos7-gcc48-opt/bin/root  
_Platform:_ lxplus6

* * *

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 28, 2020, 12:13pm UTC](https://root-forum.cern.ch/t/settitle-slows-down-rdataframe-performance/41627/2 "2020-09-28T12:13:32Z")

</div>

Hi,  
RDF produces the results lazily, the first time you access them. If you access each result as soon as you register its computation with RDF, it will have to run several event loops rather than just one that produces all results at the same time.

As a general rule of thumb, produce all the RDF results you need first, and then use them/access them/call methods on them.

EDIT: note that in this case you can construct the model with the correct title in the first place

Cheers,  
Enrico
