TChain parallel unzip

Hi,

I found references to parallel unzipping online, and tried to get a speedup that way, but it looks like the unzipping is still single-threaded. My test code and output are below. Am I missing something?

Thanks,
Phil

Code:

#include "TSystem.h"
#include "TChain.h"
#include "TMath.h"
#include "TTreeCacheUnzip.h"
#include "TROOT.h"
#include "TError.h"
#include "TStopwatch.h"
#include "TEnv.h"

#include <iostream>
#include <cstdio>

int main(int argc, char** argv)
{

  if(argc!=3){
    std::cerr << "Usage: parallelunzip filename parallel" << std::endl;
    exit(1);
  }
  const char* filename=argv[1];
  bool parallel=atoi(argv[2]);
  std::cout << "parallel unzip? " << parallel << std::endl;

  if(parallel){
    ROOT::EnableImplicitMT();
    TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable);
  }

  TChain ch("CCInclusiveReco");
  if(parallel){
    ch.SetParallelUnzip(true);
  }
  ch.SetCacheSize(30000000);

  ch.Add(filename);

  ProcInfo_t before;
  gSystem->GetProcInfo(&before);

  TStopwatch ts;

  for(size_t entry=0; entry<ch.GetEntries()/5; ++entry){
    if(entry%100000==0) std::cout << (entry/1000) << "k " << std::endl;
    ch.GetEntry();
  }

  ts.Stop();

  ProcInfo_t after;
  gSystem->GetProcInfo(&after);

  double cpu=(after.fCpuUser+after.fCpuSys - before.fCpuUser-before.fCpuSys);
  double real=ts.RealTime();

  printf("real time %.1fs, cpu time %.1fs = %.0f%% cpu\n", real, cpu, 100*cpu/real);
  return 0;

}

Output:

> ./parallelunzip /dune/data/users/rodriges/CCInclusiveReco-merged-minervame1ABCD.root 1
parallel unzip? 1
[...]
real time 8.0s, cpu time 8.0s = 100% cpu```

___
_ROOT Version:_ 6.16.00
_Platform:_ Linux
_Compiler:_ Not Provided
___

Did you compare parallel and not parallel?

Ah yes, I forgot to include that. Here’s the result of five runs without parallel unzipping, followed by five runs with parallel unzipping:

parallel 0
real time 7.8s, cpu time 7.8s = 99% cpu
real time 7.7s, cpu time 7.7s = 99% cpu
real time 8.3s, cpu time 8.2s = 99% cpu
real time 8.0s, cpu time 7.9s = 99% cpu
real time 8.1s, cpu time 8.0s = 99% cpu
parallel 1
real time 8.4s, cpu time 8.4s = 100% cpu
real time 8.2s, cpu time 8.2s = 100% cpu
real time 8.6s, cpu time 8.6s = 100% cpu
real time 8.1s, cpu time 8.1s = 99% cpu
real time 8.5s, cpu time 8.5s = 100% cpu

The time is about the same. The thing I don’t understand is why the CPU never goes above 100% for the parallel unzipping: that looks symptomatic of not multithreading at all.

I’ll let @pcanal comment on this…

Note that:

Means that you are only reading the first entry … many times (hence there is essentially no unzipping to be done).

Once this is fixed, I see

rootsrv1:2019-par-unzip pcanal$ ./parunzip Event4.root 0
parallel unzip? 0
Warning in <TClass::Init>: no dictionary for class Event is available
Warning in <TClass::Init>: no dictionary for class EventHeader is available
Warning in <TClass::Init>: no dictionary for class Track is available
0k 
real time 13.6s, cpu time 13.6s = 100% cpu
rootsrv1:2019-par-unzip pcanal$ ./parunzip Event4.root 1
parallel unzip? 1
Warning in <TClass::Init>: no dictionary for class Event is available
Warning in <TClass::Init>: no dictionary for class EventHeader is available
Warning in <TClass::Init>: no dictionary for class Track is available
0k 
real time 9.3s, cpu time 18.9s = 203% cpu

Oops. Thanks for catching that. With the fix, I see the same as you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.