Skip to content

Conversation

@sawenzel
Copy link
Contributor

@sawenzel sawenzel commented Jun 14, 2017

This is a first attempt at solving a scaling problem observed during TTree::Draw of a branch that contains a TClonesArray where each element contains another small vector container.

The fix works for me.

@phsft-bot
Copy link

Can one of the admins verify this patch?

@sawenzel
Copy link
Contributor Author

@pcanal : This is roughly what we discussed. Can you please take a look?

@pcanal
Copy link
Member

pcanal commented Jun 14, 2017

build please

@pcanal
Copy link
Member

pcanal commented Jun 14, 2017

@phsft-bot build, please

// caches to keep track of where we are across function invocations
// will avoid an O(N^2) scaling
// reset them if instance=0 is seen
static Int_t local_index_cache = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be thread_local :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course. Let us focus on the correctness for one thread for the moment. The question is then if we want to use static stuff for the cache or a member variable of the TTreeFormula. The latter would not have a penalty to access (probably).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I am very wrong :( ...

Those actually need to be data member. More than once TTreeFormula can be handled/processed during the same operation and they can also be nested. For example

tree->Draw("px:pz:fTrack[index]");

the call to EvalInstance for each i will be interleaved and the one with the index will be nested.

@phsft-bot
Copy link

Starting build on gcc49/centos7, native/mac1012, gcc49/slc6, gcc62/slc6, native/ubuntu14 with flags -Dvc=OFF -Dimt=ON -Dccache=ON
How to customize builds

@phsft-bot
Copy link

Build failed on ubuntu14/native.
See console output.

Warnings:

  • JENKINS-19022: warning: possible memory leak due to Git plugin usage; see: https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData
  • /mnt/vdb/lsf/workspace/root-pullrequests-build/root/hist/hist/src/TF1.cxx:2693:173: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘std::vector<double>::size_type {aka long unsigned int}’ [-Wformat=]
  • /mnt/vdb/lsf/workspace/root-pullrequests-build/root/tree/treeplayer/src/TTreeFormula.cxx:3424:14: warning: unused variable ‘counter’ [-Wunused-variable]

Failing tests:

@phsft-bot
Copy link

Build failed on slc6/gcc49.
See console output.

Warnings:

  • JENKINS-19022: warning: possible memory leak due to Git plugin usage; see: https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData
  • /mnt/build/jenkins/workspace/root-pullrequests-build/root/hist/hist/src/TF1.cxx:2693:173: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘std::vector<double>::size_type {aka long unsigned int}’ [-Wformat=]
  • /mnt/build/jenkins/workspace/root-pullrequests-build/root/tree/treeplayer/src/TTreeFormula.cxx:3424:14: warning: unused variable ‘counter’ [-Wunused-variable]

Failing tests:

@phsft-bot
Copy link

Build failed on slc6/gcc62.
See console output.

Warnings:

  • JENKINS-19022: warning: possible memory leak due to Git plugin usage; see: https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData
  • /mnt/build/jenkins/workspace/root-pullrequests-build/root/hist/hist/src/TF1.cxx:2693:173: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘std::vector<double>::size_type {aka long unsigned int}’ [-Wformat=]
  • /mnt/build/jenkins/workspace/root-pullrequests-build/root/tree/treeplayer/src/TTreeFormula.cxx:3424:14: warning: unused variable ‘counter’ [-Wunused-variable]

Failing tests:

// reset them if instance=0 is seen
static Int_t local_index_cache = 0;
static Int_t virt_accum_cache = 0;
if (instance==0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more stable to have here

if (instance < instance_cache)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented caching using data members + did some cleanup.

// caches to keep track of where we are across function invocations
// will avoid an O(N^2) scaling
// reset them if instance=0 is seen
static Int_t local_index_cache = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I am very wrong :( ...

Those actually need to be data member. More than once TTreeFormula can be handled/processed during the same operation and they can also be nested. For example

tree->Draw("px:pz:fTrack[index]");

the call to EvalInstance for each i will be interleaved and the one with the index will be nested.

@phsft-bot
Copy link

Build failed on mac1012/native.
See console output.

Warnings:

  • JENKINS-19022: warning: possible memory leak due to Git plugin usage; see: https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData
  • /Volumes/MacintoshHD2/build/workspace/root-pullrequests-build/root/hist/hist/src/TF1.cxx:2693:161: warning: format specifies type 'int' but the argument has type 'size_type' (aka 'unsigned long') [-Wformat]
  • /Volumes/MacintoshHD2/build/workspace/root-pullrequests-build/root/tree/treeplayer/src/TTreeFormula.cxx:3424:14: warning: unused variable 'counter' [-Wunused-variable]

Failing tests:

@sawenzel sawenzel force-pushed the swenzel/fixslowTTreeDraw branch from c470183 to 1e67dea Compare June 14, 2017 13:18
@sawenzel sawenzel changed the title WIP: Fixing an O(N^2) scaling problem caused by TTree::Draw() Fixing an O(N^2) scaling problem caused by TTree::Draw() Jun 14, 2017
@sawenzel sawenzel force-pushed the swenzel/fixslowTTreeDraw branch from 1e67dea to 229c886 Compare June 14, 2017 13:23
@sawenzel
Copy link
Contributor Author

I will be able to do some formatting. git-clang-format causes some global change however.

virtual void UpdateFormulaLeaves();

ClassDef(TTreeFormula, 10); //The Tree formula
ClassDef(TTreeFormula, 11); // The Tree formula
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to increment. The onfile format did not change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@sawenzel sawenzel force-pushed the swenzel/fixslowTTreeDraw branch 3 times, most recently from 491bd41 to 0531abb Compare June 14, 2017 13:45
@pcanal
Copy link
Member

pcanal commented Jun 16, 2017

@phsft-bot build

@phsft-bot
Copy link

Starting build on gcc49/centos7, native/mac1012, gcc49/slc6, gcc62/slc6, native/ubuntu14 with flags -Dvc=OFF -Dimt=ON -Dccache=ON
How to customize builds

@phsft-bot
Copy link

Build failed on slc6/gcc62.
See console output.

Warnings:

Failing tests:

@phsft-bot
Copy link

Build failed on ubuntu14/native.
See console output.

Warnings:

Failing tests:

@phsft-bot
Copy link

Build failed on mac1012/native.
See console output.

Warnings:

Failing tests:

@phsft-bot
Copy link

Build failed on slc6/gcc49.
See console output.

Warnings:

Failing tests:

@phsft-bot
Copy link

Build failed on centos7/gcc49.
See console output.

Warnings:

Failing tests:

@sawenzel sawenzel force-pushed the swenzel/fixslowTTreeDraw branch from 0531abb to a2b3866 Compare June 21, 2017 13:15
 * TTreeFormala::GetRealInstance repeatedly went trough a while loop
   that was trasversed again and again for each new query
   (with lineary increasing instances).
   This led to a real problem when drawing on a branch that consistent
   of many data objects (themselves containing small variable sized containers).

 * The problem is fixed by caching the state of a previous call.
@sawenzel sawenzel force-pushed the swenzel/fixslowTTreeDraw branch from a2b3866 to c172e22 Compare June 21, 2017 13:18
@pcanal
Copy link
Member

pcanal commented Jun 21, 2017

@phsft-bot build, please

@phsft-bot
Copy link

Starting build on gcc49/centos7, native/mac1012, gcc49/slc6, gcc62/slc6, native/ubuntu14 with flags -Dvc=OFF -Dimt=ON -Dccache=ON
How to customize builds

@phsft-bot
Copy link

Build failed on centos7/gcc49.
See console output.

Warnings:

@amadio
Copy link
Member

amadio commented Jul 25, 2017

Hi @sawenzel, has this been merged in another PR? If not, could you please rebase and push so that we can test against the latest master? Most unrelated test failures from above have been fixed. Thanks!

@sawenzel
Copy link
Contributor Author

sawenzel commented Aug 3, 2017

I think this has been merged can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants