43 class TProofPerfAnalysis::TWrkInfo :
public TNamed {
45 TWrkInfo(
const char *ord,
const char *name) :
46 TNamed(ord, name), fPackets(0), fRemotePackets(0), fEventsProcessed(0),
47 fBytesRead(0), fLatency(0), fProcTime(0), fCpuTime(0), fStart(0), fStop(-1),
48 fRateT(0), fRateRemoteT(0), fMBRateT(0), fMBRateRemoteT(0), fLatencyT(0) { }
49 virtual ~TWrkInfo() { SafeDelete(fRateT); SafeDelete(fRateRemoteT);
50 SafeDelete(fMBRateT); SafeDelete(fMBRateRemoteT);
51 SafeDelete(fLatencyT); }
55 Long64_t fEventsProcessed;
67 TGraph *fMBRateRemoteT;
70 Double_t AvgRate() {
if (fProcTime > 0)
return (fEventsProcessed/fProcTime);
return -1.; }
71 Double_t AvgIO() {
if (fProcTime > 0)
return (fBytesRead/fProcTime);
return -1.; }
73 void Print(Option_t * =
"")
const {
74 Printf(
" +++ TWrkInfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
75 Printf(
" +++ Worker: %s, %s", GetName(), GetTitle());
76 Printf(
" +++ Activity interval: %f -> %f", fStart, fStop);
77 Printf(
" +++ Amounts processed: %d packets (%d remote), %lld evts, %lld bytes",
78 fPackets, fRemotePackets, fEventsProcessed, fBytesRead);
80 Printf(
" +++ Processing time: %f s (CPU: %f s)", fProcTime, fCpuTime);
81 Printf(
" +++ Averages: %f evts/s, %f MB/s", (Double_t)fEventsProcessed / fProcTime, (Double_t)fBytesRead /1024./1024./fProcTime);
83 Printf(
" +++ Total latency: %f", fLatency);
84 Printf(
" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
87 Int_t Compare(
const TObject *o)
const { TWrkInfo *wi = (TWrkInfo *)o;
89 if (fStop < wi->fStop) {
91 }
else if (fStop == wi->fStop) {
99 class TProofPerfAnalysis::TPackInfo :
public TNamed {
101 TPackInfo(
const char *ord,
const char *host) : TNamed(ord, host), fStart(0), fStop(-1), fSize(0), fMBRate(0.) { }
102 TPackInfo(
const char *ord,
const char *host, Float_t start, Float_t stop, Long64_t sz, Double_t mbr)
103 : TNamed(ord, host), fStart(start), fStop(stop), fSize(sz), fMBRate(mbr) { }
108 void Print(Option_t *opt=
"")
const {
109 if (!strcmp(opt,
"S")) {
110 Printf(
" \t%10lld evts, \t%12.2f MB/s, \t%12.3f -> %12.3f s", fSize, fMBRate, fStart, fStop);
112 Printf(
" %s:\t%s \t%10lld evts, \t%12.2f MB/s, \t%12.3f -> %12.3f s", GetTitle(), GetName(), fSize, fMBRate, fStart, fStop);
117 class TProofPerfAnalysis::TWrkInfoFile :
public TNamed {
119 TWrkInfoFile(
const char *ord,
const char *name) : TNamed(ord, name) { }
120 ~TWrkInfoFile() {fPackets.SetOwner(kFALSE); fPackets.Clear(
"nodelete");}
122 void Print(Option_t *opt=
"")
const {
123 if (!strcmp(opt,
"R")) {
124 Printf(
" Worker: %s,\tpacket(s): %d", GetName(), fPackets.GetSize());
126 Printf(
" Worker: %s,\t%d packet(s) from file: %s", GetName(), fPackets.GetSize(), GetTitle());
128 TIter nxp(&fPackets);
130 while ((o = nxp())) { o->Print(
"S"); }
134 class TProofPerfAnalysis::TWrkEntry :
public TObject {
136 TWrkEntry(Double_t xx, Double_t er, Double_t mbr, Double_t pt) : fXx(xx), fEvtRate(er), fMBRate(mbr), fProcTime(pt) { }
141 void Print(Option_t * =
"")
const { Printf(
"%.4f \t%.3f evt/s \t%.3f MB/s \t%.3f s ", fXx, fEvtRate, fMBRate, fProcTime); }
146 class TProofPerfAnalysis::TFileInfo :
public TNamed {
148 TFileInfo(
const char *name,
const char *srv) :
149 TNamed(name, srv), fPackets(0), fRPackets(0), fStart(0), fStop(-1),
150 fSizeAvg(0), fSizeMax(-1.), fSizeMin(-1.),
151 fMBRateAvg(0), fMBRateMax(-1.), fMBRateMin(-1.), fSizeP(0),
152 fRateP(0), fRatePRemote(0), fMBRateP(0), fMBRatePRemote(0) { }
153 virtual ~TFileInfo() {SafeDelete(fSizeP);
154 SafeDelete(fRateP); SafeDelete(fRatePRemote);
155 SafeDelete(fMBRateP); SafeDelete(fMBRatePRemote);
156 fPackList.SetOwner(kTRUE); fPackList.Clear();
157 fWrkList.SetOwner(kTRUE); fWrkList.Clear();
158 fRWrkList.SetOwner(kTRUE); fRWrkList.Clear();}
180 TGraph *fRatePRemote;
182 TGraph *fMBRatePRemote;
184 void Print(Option_t *opt =
"")
const {
185 Printf(
" +++ TFileInfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
186 Printf(
" +++ Server: %s", GetTitle());
187 Printf(
" +++ File: %s", GetName());
188 Printf(
" +++ Processing interval: %f -> %f", fStart, fStop);
189 Printf(
" +++ Packets: %d (%d remote)", fPackets, fRPackets);
190 Printf(
" +++ Processing wrks: %d (%d remote)", fWrkList.GetSize(), fRWrkList.GetSize());
191 if (!strcmp(opt,
"P")) fPackList.Print();
192 if (!strcmp(opt,
"WP")) fWrkList.Print(
"R");
194 Printf(
" +++ MB rates: %f MB/s (avg), %f MB/s (min), %f MB/s (max)",
195 fMBRateAvg / fPackets, fMBRateMin, fMBRateMax);
196 Printf(
" +++ Sizes: %lld (avg), %lld (min), %lld (max)",
197 fSizeAvg / fPackets, fSizeMin, fSizeMax);
199 Printf(
" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
202 Int_t Compare(
const TObject *o)
const { TFileInfo *wi = (TFileInfo *)o;
204 if (fStop < wi->fStop) {
206 }
else if (fStop == wi->fStop) {
213 Bool_t TProofPerfAnalysis::fgDebug = kTRUE;
217 TProofPerfAnalysis::TProofPerfAnalysis(
const char *perffile,
218 const char *title,
const char *treename)
219 : TNamed(perffile, title), fFile(0), fTreeName(treename), fTree(0),
220 fInitTime(-1.), fMergeTime(-1.), fMaxTime(-1.),
221 fEvents(0), fPackets(0),
222 fEvtRateMax(-1.), fMBRateMax(-1.), fLatencyMax(-1.),
223 fEvtRate(0), fEvtRateRun(0), fMBRate(0), fMBRateRun(0),
224 fEvtRateAvgMax(-1.), fMBRateAvgMax(-1.),
225 fEvtRateAvg(-1.), fMBRateAvg(0),
226 fFileResult(
""), fSaveResult(kFALSE),
230 if (!title) SetTitle(
"PROOF Performance Analysis");
233 fFile = TFile::Open(perffile);
234 if (!fFile || (fFile && fFile->IsZombie())) {
236 Error(
"TProofPerfAnalysis",
"problems opening file '%s'",
237 perffile ? perffile :
"<undef>");
238 SetBit(TObject::kInvalidObject);
243 if (fTreeName.Contains(
"/")) {
244 fDirName = gSystem->DirName(fTreeName);
245 fTreeName = gSystem->BaseName(fTreeName);
249 if (fTreeName.BeginsWith(
"+"))
250 fTreeName.Replace(0, 1,
"PROOF_PerfStats");
253 TDirectory *dir = fFile;
254 if (!fDirName.IsNull()) {
255 if (!(dir = dynamic_cast<TDirectory *>(fFile->Get(fDirName)))) {
256 Error(
"TProofPerfAnalysis",
"directory '%s' not found or not loadable", fDirName.Data());
259 SetBit(TObject::kInvalidObject);
267 Error(
"TProofPerfAnalysis",
"tree '%s' not found or not loadable", fTreeName.Data());
270 SetBit(TObject::kInvalidObject);
274 Printf(
" +++ TTree '%s' has %lld entries", fTreeName.Data(), fTree->GetEntries());
289 TProofPerfAnalysis::TProofPerfAnalysis(TTree *tree,
const char *title)
290 : TNamed(
"", title), fFile(0), fTree(0),
291 fInitTime(-1.), fMergeTime(-1.), fMaxTime(-1.),
292 fEvents(0), fPackets(0),
293 fEvtRateMax(-1.), fMBRateMax(-1.), fLatencyMax(-1.),
294 fEvtRate(0), fEvtRateRun(0), fMBRate(0), fMBRateRun(0),
295 fEvtRateAvgMax(-1.), fMBRateAvgMax(-1.),
296 fEvtRateAvg(-1.), fMBRateAvg(0),
301 SetBit(TObject::kInvalidObject);
306 if (!title) SetTitle(
"PROOF Performance Analysis");
309 fTreeName = fTree->GetName();
310 SetName(TString::Format(
"heap_%s", fTreeName.Data()));
313 if (fTreeName.BeginsWith(
"+"))
314 fTreeName.Replace(0, 1,
"PROOF_PerfStats");
317 Printf(
" +++ TTree '%s' has %lld entries", fTreeName.Data(), fTree->GetEntries());
332 TProofPerfAnalysis::~TProofPerfAnalysis()
335 SafeDelete(fPackets);
336 if (fFile) fFile->Close();
343 TString TProofPerfAnalysis::GetCanvasTitle(
const char *t)
345 if (fTitle.IsNull())
return TString(t);
348 if (t && strlen(t) > 0) {
349 newt.Form(
"%s - %s", t, GetTitle());
363 void TProofPerfAnalysis::LoadTree(TDirectory *dir)
369 if ((fTree = dynamic_cast<TTree *>(dir->Get(fTreeName))))
return;
371 TRegexp re(fTreeName);
373 TIter nxk(dir->GetListOfKeys());
375 while ((k = (TKey *) nxk())) {
376 if (!strcmp(k->GetClassName(),
"TDirectoryFile")) {
377 TDirectory *kdir = (TDirectory *) dir->Get(k->GetName());
380 }
else if (!strcmp(k->GetClassName(),
"TTree")) {
381 TString tn(k->GetName());
382 if (tn.Index(re) != kNPOS) {
383 if ((fTree = dynamic_cast<TTree *>(dir->Get(tn)))) {
385 if (fgDebug) Printf(
" +++ Found and loaded TTree '%s'", tn.Data());
400 void TProofPerfAnalysis::FileDist(Bool_t writedet)
403 Error(
"FileDist",
"not a valid instance - do nothing");
408 TList *wrkList =
new TList;
409 TList *srvList =
new TList;
410 GetWrkFileList(wrkList, srvList);
411 Info(
"FileDist",
"%d workers were active during this query", wrkList->GetSize());
412 Info(
"FileDist",
"%d servers were active during this query", srvList->GetSize());
417 TNamed *sn = 0, *wn = 0;
418 while ((sn = (TNamed *)nxs())) {
420 while ((wn = (TNamed *) nxw())) {
421 if (!strcmp(TUrl(sn->GetName()).GetHostFQDN(), wn->GetTitle())) {
422 sn->SetTitle(wn->GetName());
428 TList *nwl =
new TList;
429 TList *nsl =
new TList;
431 while ((wn = (TNamed *) nxw())) {
434 while ((nwn = (TNamed *) nnxw())) {
435 if (CompareOrd(wn->GetName(), nwn->GetName()) < 0) {
436 nwl->AddBefore(nwn, wn);
440 if (!nwn) nwl->Add(wn);
443 while ((sn = (TNamed *)nxs())) {
444 if (!strcmp(sn->GetTitle(), wn->GetName())) {
447 while ((nsn = (TNamed *) nnxs())) {
448 if (CompareOrd(sn->GetTitle(), nsn->GetTitle()) < 0) {
449 nsl->AddBefore(nsn, sn);
453 if (!nsn) nsl->Add(sn);
457 if (sn) srvList->Remove(sn);
461 while ((sn = (TNamed *)nxs())) {
465 wrkList->SetOwner(kFALSE);
466 srvList->SetOwner(kFALSE);
477 if (srvList->GetSize() == 1) {
479 Printf(
"\n +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
480 Printf(
" + Only one data server found: full analysis meaningful + ");
481 Printf(
" + only when there are more file servers + ");
482 Printf(
" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
486 TH1F *hxpak =
new TH1F(
"hxpak",
"MBytes / Worker",
487 wrkList->GetSize(), 0., (Double_t)wrkList->GetSize());
488 hxpak->SetDirectory(0);
489 hxpak->SetMinimum(0.);
490 hxpak->GetXaxis()->SetTitle(
"Worker");
495 while ((wn = (TNamed *)nxsw())) {
496 hxpak->GetXaxis()->SetBinLabel(j++, wn->GetName());
500 FillFileDistOneSrv(hxpak, writedet);
503 gStyle->SetOptStat(0);
505 TCanvas *c2 =
new TCanvas(
"cv-hxpak", GetCanvasTitle(hxpak->GetTitle()), 800,350,700,700);
512 TH1F *hfdis =
new TH1F(
"hfdis",
"Packet dist",
513 srvList->GetSize(), 0., (Double_t)srvList->GetSize());
514 hfdis->SetDirectory(0);
515 hfdis->SetMinimum(0);
516 hfdis->GetXaxis()->SetTitle(
"Server");
517 TH1F *hbdis =
new TH1F(
"hbdis",
"MBytes dist",
518 srvList->GetSize(), 0., (Double_t)srvList->GetSize());
519 hbdis->SetDirectory(0);
520 hbdis->SetMinimum(0);
521 hbdis->GetXaxis()->SetTitle(
"Server");
523 TH2F *hxpak =
new TH2F(
"hxpak",
"MBytes / {Worker,Server}",
524 srvList->GetSize(), 0., (Double_t)srvList->GetSize(),
525 wrkList->GetSize(), 0., (Double_t)wrkList->GetSize());
526 hxpak->SetDirectory(0);
527 hxpak->GetYaxis()->SetTitle(
"Worker");
528 hxpak->GetXaxis()->SetTitle(
"Server");
529 hxpak->GetXaxis()->SetTitleOffset(1.4);
530 hxpak->GetYaxis()->SetTitleOffset(1.7);
535 while ((wn = (TNamed *)nxsw())) {
536 hxpak->GetYaxis()->SetBinLabel(j++, wn->GetName());
540 while ((sn = (TNamed *)nxss())) {
541 hfdis->GetXaxis()->SetBinLabel(j, sn->GetName());
542 hbdis->GetXaxis()->SetBinLabel(j, sn->GetName());
543 hxpak->GetXaxis()->SetBinLabel(j++, sn->GetName());
547 FillFileDist(hfdis, hbdis, hxpak, writedet);
551 while ((sn = (TNamed *)nxss())) {
552 TString lab(sn->GetName());
553 lab = TUrl(sn->GetName()).GetHost();
554 if (strcmp(sn->GetTitle(),
"remote") && lab.Index(
".") != kNPOS) lab.Remove(lab.Index(
"."));
555 hfdis->GetXaxis()->SetBinLabel(j, lab);
556 hbdis->GetXaxis()->SetBinLabel(j, lab);
557 hxpak->GetXaxis()->SetBinLabel(j++, lab);
561 gStyle->SetOptStat(0);
563 TCanvas *c1 =
new TCanvas(
"cv-hfdis", GetCanvasTitle(hfdis->GetTitle()), 800,50,700,700);
565 TPad *pad1 = (TPad *) c1->GetPad(1);
566 TPad *pad2 = (TPad *) c1->GetPad(2);
573 TCanvas *c2 =
new TCanvas(
"cv-hxpak", GetCanvasTitle(hxpak->GetTitle()), 500,350,700,700);
575 DoDraw(hxpak,
"lego");
585 void TProofPerfAnalysis::GetWrkFileList(TList *wl, TList *sl)
587 if (!wl || !sl)
return;
591 TPerfEvent* pep = &pe;
592 fTree->SetBranchAddress(
"PerfEvents", &pep);
593 Long64_t entries = fTree->GetEntries();
594 TNamed *wn = 0, *sn = 0;
595 for (Long64_t k=0; k<entries; k++) {
598 if (pe.fType != TVirtualPerfStats::kPacket)
continue;
600 TString wrk(TUrl(pe.fSlaveName.Data()).GetHostFQDN());
601 wn = (TNamed *) wl->FindObject(pe.fSlave.Data());
603 wn =
new TNamed(pe.fSlave.Data(), wrk.Data());
607 TUrl uf(pe.fFileName);
608 TString srv(uf.GetUrl());
609 Int_t ifn = srv.Index(uf.GetFile());
610 if (ifn != kNPOS) srv.Remove(ifn);
611 sn = (TNamed *) sl->FindObject(srv.Data());
613 sn =
new TNamed(srv.Data(),
"remote");
626 Int_t TProofPerfAnalysis::CompareOrd(
const char *ord1,
const char *ord2)
628 TString o1(ord1), o2(ord2), p1, p2;
629 Int_t o1d = 0, o2d = 0;
630 if ((o1d = o1.CountChar(
'.')) > (o2d = o2.CountChar(
'.'))) {
632 }
else if (o1d < o2d) {
635 o1.ReplaceAll(
".",
" ");
636 o2.ReplaceAll(
".",
" ");
637 Bool_t b1 = o1.Tokenize(p1, o1d,
" ");
638 Bool_t b2 = o2.Tokenize(p2, o2d,
" ");
640 if (p1.Atoi() > p2.Atoi()) {
642 }
else if (p1.Atoi() < p2.Atoi()) {
645 b1 = o1.Tokenize(p1, o1d,
" ");
646 b2 = o2.Tokenize(p2, o2d,
" ");
651 }
else if (b2 && !b1) {
662 void TProofPerfAnalysis::FillFileDist(TH1F *hf, TH1F *hb, TH2F *hx, Bool_t wdet)
664 if (!hf || !hb || !hx)
return;
669 fnout.Form(
"%s-FileDist-Details.txt", GetName());
670 if (!(fout = fopen(fnout.Data(),
"w"))) {
671 Warning(
"FillFileDist",
"asked to save details in '%s' but file could"
672 " not be open (errno: %d)", fnout.Data(), (int)errno);
674 Info(
"FillFileDist",
"saving details to '%s'", fnout.Data());
679 TPerfEvent* pep = &pe;
680 fTree->SetBranchAddress(
"PerfEvents",&pep);
681 Long64_t entries = fTree->GetEntries();
682 for (Long64_t k=0; k<entries; k++) {
685 if (pe.fType != TVirtualPerfStats::kPacket)
continue;
687 TString wrk(pe.fSlave.Data());
688 TUrl uf(pe.fFileName);
689 TString srv(uf.GetUrl());
690 Int_t ifn = srv.Index(uf.GetFile());
691 if (ifn != kNPOS) srv.Remove(ifn);
693 Double_t xhf = hf->GetXaxis()->GetBinCenter(hf->GetXaxis()->FindBin(srv.Data()));
694 Double_t xhx = hx->GetXaxis()->GetBinCenter(hx->GetXaxis()->FindBin(srv.Data()));
695 Double_t yhx = hx->GetYaxis()->GetBinCenter(hx->GetYaxis()->FindBin(wrk.Data()));
698 fprintf(fout,
"%s,%s -> %f,%f (%f)\n",
699 srv.Data(), wrk.Data(), xhx, yhx, pe.fBytesRead / 1024.);
702 hb->Fill(xhf, pe.fBytesRead / 1024. / 1024.);
703 hx->Fill(xhx, yhx, pe.fBytesRead / 1024. / 1024.);
705 if (fout) fclose(fout);
713 void TProofPerfAnalysis::FillFileDistOneSrv(TH1F *hx, Bool_t wdet)
720 fnout.Form(
"%s-FileDist-Details.txt", GetName());
721 if (!(fout = fopen(fnout.Data(),
"w"))) {
722 Warning(
"FillFileDistOneSrv",
"asked to save details in '%s' but file could"
723 " not be open (errno: %d)", fnout.Data(), (int)errno);
725 Info(
"FillFileDistOneSrv",
"saving details to '%s'", fnout.Data());
730 TPerfEvent* pep = &pe;
731 fTree->SetBranchAddress(
"PerfEvents",&pep);
732 Long64_t entries = fTree->GetEntries();
733 for (Long64_t k=0; k<entries; k++) {
736 if (pe.fType != TVirtualPerfStats::kPacket)
continue;
738 TString wrk(pe.fSlave.Data());
739 TUrl uf(pe.fFileName);
740 TString srv(uf.GetUrl());
741 Int_t ifn = srv.Index(uf.GetFile());
742 if (ifn != kNPOS) srv.Remove(ifn);
744 Double_t xhx = hx->GetXaxis()->GetBinCenter(hx->GetXaxis()->FindBin(wrk.Data()));
747 fprintf(fout,
"%s,%s -> %f (%f)\n",
748 srv.Data(), wrk.Data(), xhx, pe.fBytesRead / 1024.);
750 hx->Fill(xhx, pe.fBytesRead / 1024. / 1024.);
752 if (fout) fclose(fout);
760 void TProofPerfAnalysis::WorkerActivity()
763 Error(
"WorkerActivity",
"not a valid instance - do nothing");
768 if (!WrkInfoOK()) FillWrkInfo();
770 Error(
"WorkerActivity",
"workers information not available - do nothing");
776 if ((o = gDirectory->FindObject(
"act10")))
delete o;
777 Float_t t0 = fMergeTime - 2.* (fMaxTime - fMergeTime);
778 Float_t t1 = 2.*fInitTime;
779 if (t1 > t0) t1 = t0;
780 TH1F *hact10 =
new TH1F(
"act10",
"Worker activity start (seconds)", 50, 0., t1);
781 hact10->GetXaxis()->SetTitle(
"Query Processing Time (s)");
782 if ((o = gDirectory->FindObject(
"act11")))
delete o;
783 TH1F *hact11 =
new TH1F(
"act11",
"Worker activity stop (seconds)", 50, t0, fMaxTime);
784 hact11->GetXaxis()->SetTitle(
"Query Processing Time (s)");
785 if ((o = gDirectory->FindObject(
"act2")))
delete o;
786 TH1F *hact2 =
new TH1F(
"act2",
"End of activity (seconds)", 50, t0, fMaxTime);
787 hact2->GetXaxis()->SetTitle(
"Query Processing Time (s)");
790 Int_t curoptstat = gStyle->GetOptStat();
791 gStyle->SetOptStat(1100);
794 TIter nxw(&fWrksInfo);
796 while ((wi = (TWrkInfo *)nxw())) {
798 for (j = 1; j < hact10->GetNbinsX()+1 ; j++) {
799 if (wi->fStart < hact10->GetBinLowEdge(j))
800 hact10->Fill(hact10->GetBinCenter(j));
802 for (j = 1; j < hact11->GetNbinsX()+1 ; j++) {
803 if (wi->fStop > hact11->GetBinLowEdge(j))
804 hact11->Fill(hact11->GetBinCenter(j));
806 hact2->Fill(wi->fStop);
810 TCanvas *c1 =
new TCanvas(
"perf", GetCanvasTitle(
"Activity histos"), 800,10,700,780);
812 TPad *pad1 = (TPad *) c1->GetPad(1);
814 TPad *pad10 = (TPad *) pad1->GetPad(1);
815 TPad *pad11 = (TPad *) pad1->GetPad(2);
820 TPad *pad2 = (TPad *) c1->GetPad(2);
827 gStyle->SetOptStat(curoptstat);
837 void TProofPerfAnalysis::PrintWrkInfo(Int_t showlast)
840 Int_t k = fWrksInfo.GetSize();
841 TIter nxw(&fWrksInfo);
843 while ((wi = (TWrkInfo *)nxw())) {
846 if (showlast < 0 || k < showlast) wi->Print();
855 void TProofPerfAnalysis::PrintWrkInfo(
const char *wn)
857 if (!wn || (wn && strlen(wn) <= 0)) {
858 Error(
"PrintWrkInfo",
"worker name or host must be defined!");
863 TWrkInfo *wi = (TWrkInfo *) fWrksInfo.FindObject(wn);
869 TIter nxw(&fWrksInfo);
870 while ((wi = (TWrkInfo *)nxw())) {
871 TString n(wi->GetName()), t(wi->GetTitle());
873 while (ww.Tokenize(w, from,
"[, ]")) {
874 TRegexp re(w, kTRUE);
875 if (n.Index(re) != kNPOS || t.Index(re) != kNPOS) wi->Print();
885 void TProofPerfAnalysis::PrintFileInfo(Int_t showlast,
const char *opt,
const char *out)
888 if (out && strlen(out) > 0) gSystem->RedirectOutput(out,
"w", &rh);
891 Int_t k = fFilesInfo.GetSize();
892 TIter nxf(&fFilesInfo);
894 while ((fi = (TFileInfo *)nxf())) {
897 if (showlast < 0 || k < showlast) fi->Print(opt);
900 if (out && strlen(out) > 0) gSystem->RedirectOutput(0, 0, &rh);
908 void TProofPerfAnalysis::PrintFileInfo(
const char *fn,
const char *opt,
const char *out)
910 if (!fn || (fn && strlen(fn) <= 0)) {
911 Error(
"PrintFileInfo",
"file path must be defined!");
916 if (out && strlen(out) > 0) gSystem->RedirectOutput(out,
"w", &rh);
919 TFileInfo *fi = (TFileInfo *) fFilesInfo.FindObject(fn);
925 TIter nxf(&fFilesInfo);
926 while ((fi = (TFileInfo *)nxf())) {
927 TString n(fi->GetName()), s(fi->GetTitle());
929 while (fw.Tokenize(f, from,
"[, ]")) {
930 TRegexp re(f, kTRUE);
931 if (n.Index(re) != kNPOS || s.Index(re) != kNPOS) fi->Print(opt);
936 if (out && strlen(out) > 0) gSystem->RedirectOutput(0, 0, &rh);
942 void TProofPerfAnalysis::FillWrkInfo(Bool_t force)
945 if (fWrksInfo.GetSize() > 0 && !force)
return;
948 fWrksInfo.SetOwner(kTRUE);
957 TList *wl =
new TList;
960 TPerfEvent* pep = &pe;
961 fTree->SetBranchAddress(
"PerfEvents",&pep);
962 Long64_t entries = fTree->GetEntries();
965 Int_t nraw = entries * 2, jj = 0, kk = 0;
966 Double_t *xraw =
new Double_t[nraw];
967 for (Long64_t k=0; k<entries; k++) {
970 if (pe.fType == TVirtualPerfStats::kPacket) {
971 Float_t stop = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
972 Float_t start = stop - pe.fProcTime;
979 Int_t *jidx =
new Int_t[nbins];
980 memset(jidx, 0, nbins *
sizeof(Int_t));
981 TMath::Sort(nbins, xraw, jidx, kFALSE);
982 Double_t *xbins =
new Double_t[nbins];
984 for (kk = 0; kk < nbins; kk++) {
985 Double_t xtmp = xraw[jidx[kk]];
986 if (jj == 0 || xtmp > xbins[jj - 1] + .5) {
996 Int_t nbin = nbins - 1;
998 if ((o = gDirectory->FindObject(
"gEvtRate")))
delete o;
999 fEvtRate =
new TH1F(
"gEvtRate",
"Total event processing rate (evt/s)", nbin, xbins);
1000 fEvtRate->SetMinimum(0.);
1001 fEvtRate->SetStats(kFALSE);
1002 fEvtRate->SetFillColor(kCyan-8);
1003 fEvtRate->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1004 if ((o = gDirectory->FindObject(
"gEvtRateAvg")))
delete o;
1005 fEvtRateRun =
new TH1F(
"gEvtRateAvg",
"Event processing rate running average (evt/s)", nbin, xbins);
1006 fEvtRateRun->SetMinimum(0.);
1007 fEvtRateRun->SetStats(kFALSE);
1008 fEvtRateRun->SetLineColor(kBlue);
1009 fEvtRateRun->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1010 if ((o = gDirectory->FindObject(
"gMBRate")))
delete o;
1011 fMBRate =
new TH1F(
"gMBRate",
"Total processing rate (MB/s)", nbin, xbins);
1012 fMBRate->SetMinimum(0.);
1013 fMBRate->SetStats(kFALSE);
1014 fMBRate->SetFillColor(kCyan-8);
1015 fMBRate->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1016 if ((o = gDirectory->FindObject(
"gMBRateAvg")))
delete o;
1017 fMBRateRun =
new TH1F(
"gMBRateAvg",
"Processing rate running average (MB/s)", nbin, xbins);
1018 fMBRateRun->SetMinimum(0.);
1019 fMBRateRun->SetStats(kFALSE);
1020 fMBRateRun->SetLineColor(kBlue);
1021 fMBRateRun->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1026 TList *gwl = 0, *gbl = 0;
1030 for (Long64_t k=0; k<entries; k++) {
1033 if (pe.fType == TVirtualPerfStats::kPacket) {
1035 if (!(wi = (TWrkInfo *) wl->FindObject(pe.fSlave.Data()))) {
1036 wi =
new TWrkInfo(pe.fSlave.Data(), pe.fSlaveName.Data());
1038 wi->fRateT =
new TGraph(100);
1039 wi->fRateRemoteT =
new TGraph(100);
1040 wi->fMBRateT =
new TGraph(100);
1041 wi->fMBRateRemoteT =
new TGraph(100);
1042 wi->fLatencyT =
new TGraph(100);
1045 Float_t stop = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1046 Float_t start = stop - pe.fProcTime;
1047 if (wi->fPackets <= 0) {
1052 TUrl uf(pe.fFileName), uw(pe.fSlaveName);
1054 wi->fEventsProcessed += pe.fEventsProcessed;
1055 wi->fBytesRead += pe.fBytesRead;
1056 wi->fLatency += pe.fLatency;
1057 wi->fProcTime += pe.fProcTime;
1058 wi->fCpuTime += pe.fCpuTime;
1061 Double_t ert = pe.fEventsProcessed / pe.fProcTime ;
1062 Double_t brt = pe.fBytesRead / pe.fProcTime / 1024. / 1024. ;
1063 wi->fRateT->SetPoint(wi->fPackets, tt, ert);
1064 if (brt > 0.) wi->fMBRateT->SetPoint(wi->fPackets, tt, brt);
1065 wi->fLatencyT->SetPoint(wi->fPackets, tt, pe.fLatency);
1066 if (!pe.fFileName.IsNull() && strcmp(uf.GetHostFQDN(), uw.GetHostFQDN())) {
1067 wi->fRateRemoteT->SetPoint(wi->fRemotePackets, tt, ert);
1068 wi->fMBRateRemoteT->SetPoint(wi->fRemotePackets, tt, brt);
1069 wi->fRemotePackets++;
1072 if (ert > fEvtRateMax) fEvtRateMax = ert;
1073 if (brt > fMBRateMax) fMBRateMax = brt;
1074 if (pe.fLatency > fLatencyMax) fLatencyMax = pe.fLatency;
1077 for (kk = 1; kk <= nbins; kk++) {
1078 Double_t mi = fEvtRate->GetBinLowEdge(kk);
1079 if (mi > stop)
break;
1080 Double_t wd = fEvtRate->GetBinWidth(kk);
1081 Double_t mx = mi + wd;
1082 Double_t xx = fEvtRate->GetBinCenter(kk);
1084 Double_t olap = stop - mi;
1085 if (start > mi) olap = mx - start;
1087 TString sb = TString::Format(
"%d", kk);
1088 if (!(gbl = (TList *) gBins.FindObject(sb))) {
1093 if (!(gwl = (TList *) gbl->FindObject(pe.fSlave))) {
1095 gwl->SetName(pe.fSlave);
1098 gwl->Add(
new TWrkEntry(xx, ert, brt, pe.fProcTime));
1104 if (pe.fProcTime > 0.) {
1105 Printf(
" +++ %s #:%d at:%fs lat:%fs proc:%fs evts:%lld bytes:%lld (rates:%f evt/s, %f MB/s)",
1106 wi->GetName(), wi->fPackets, fMaxTime - pe.fProcTime,
1107 pe.fLatency, pe.fProcTime, pe.fEventsProcessed, pe.fBytesRead,
1110 Printf(
" +++ %s #:%d at:%fs lat:%fs proc:%fs rate:-- evt/s (-- bytes/s)",
1111 wi->GetName(), wi->fPackets, fMaxTime, pe.fLatency, pe.fProcTime);
1114 }
else if (pe.fType == TVirtualPerfStats::kStart) {
1115 Float_t start = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1116 if (fDebug > 1) Printf(
" +++ %s Start: %f s", pe.fEvtNode.Data(), start);
1117 }
else if (pe.fType == TVirtualPerfStats::kStop) {
1118 Float_t stop = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1119 if (fDebug > 1) Printf(
" +++ %s Stop: %f s", pe.fEvtNode.Data(), stop);
1121 if (fDebug > 2) Printf(
" +++ Event type: %d", pe.fType);
1127 while ((gbl = (TList *) nxb())) {
1130 while ((gwl = (TList *) nxw())) {
1131 Double_t er = 0, br = 0, pt = 0, xx = 0;
1134 while ((we = (TWrkEntry *) nxp())) {
1135 if (we->fProcTime > 0) {
1136 er += we->fEvtRate * we->fProcTime;
1137 br += we->fMBRate * we->fProcTime;
1138 pt += we->fProcTime;
1145 fEvtRate->Fill(xx, er);
1146 if (br > 0.) fMBRate->Fill(xx, br);
1152 Double_t er = 0, br = 0, pt = 0;
1153 for (kk = 1; kk < nbins; kk++) {
1154 Double_t wd = fEvtRate->GetBinWidth(kk);
1155 Double_t wx = fEvtRate->GetBinCenter(kk);
1156 Double_t wer = fEvtRate->GetBinContent(kk);
1157 Double_t wbr = fMBRate->GetBinContent(kk);
1172 if (er > fEvtRateAvgMax) fEvtRateAvgMax = er;
1173 if (br > fMBRateAvgMax) fMBRateAvgMax = br;
1177 fEvtRateRun->Fill(wx, er);
1178 fMBRateRun->Fill(wx, br);
1184 while ((wi = (TWrkInfo *) nxw())) {
1186 if (wi->fStart > fInitTime) fInitTime = wi->fStart;
1188 wi->fRateT->Set(wi->fPackets);
1189 wi->fRateRemoteT->Set(wi->fRemotePackets);
1190 wi->fLatencyT->Set(wi->fPackets);
1191 wi->fMBRateT->Set(wi->fPackets);
1192 wi->fMBRateRemoteT->Set(wi->fRemotePackets);
1194 wl->SetOwner(kFALSE);
1198 fMergeTime = fMaxTime;
1199 Int_t rsw = (fWrksInfo.GetSize() > 1) ? 2 : 1, ksw = 0;
1200 TIter nxsw(&fWrksInfo);
1201 while ((wi = (TWrkInfo *) nxsw())) {
1202 if (wi->fStop > 0.) ksw++;
1203 if (ksw == rsw)
break;
1205 if (wi) fMergeTime = wi->fStop;
1208 SafeDelete(fEvents);
1209 SafeDelete(fPackets);
1210 fEvents =
new TH1F(
"hevents",
"Events per worker", fWrksInfo.GetSize(), -.5, fWrksInfo.GetSize()-.5);
1211 fEvents->SetDirectory(0);
1212 fPackets =
new TH1F(
"hpackets",
"Packets per worker", fWrksInfo.GetSize(), -.5, fWrksInfo.GetSize()-.5);
1213 fPackets->SetDirectory(0);
1215 TIter nxwi(&fWrksInfo);
1216 while ((wi = (TWrkInfo *)nxwi())) {
1217 fEvents->GetXaxis()->SetBinLabel(j+1, wi->GetName());
1218 fEvents->Fill(j, wi->fEventsProcessed);
1219 fPackets->GetXaxis()->SetBinLabel(j+1, wi->GetName());
1220 fPackets->Fill(j++, wi->fPackets);
1222 fEvents->SetMinimum(0.);
1223 fPackets->SetMinimum(0.);
1224 fEvents->SetFillColor(38);
1225 fPackets->SetFillColor(38);
1226 fEvents->GetYaxis()->SetTitle(
"Events");
1227 fEvents->GetXaxis()->SetTitle(
"Worker");
1228 fPackets->GetYaxis()->SetTitle(
"Packets");
1229 fPackets->GetXaxis()->SetTitle(
"Worker");
1232 if (fgDebug) Summary();
1239 void TProofPerfAnalysis::Summary(Option_t *opt,
const char *out)
1242 RedirectHandle_t rh;
1244 const char *m = (o.BeginsWith(
"+")) ?
"a" :
"w";
1245 o.Remove(TString::kLeading,
'+');
1246 gSystem->RedirectOutput(o, m, &rh);
1250 if (!strcmp(opt,
"S")) {
1252 Printf(
"%d %f %f %f %f %f %f %f",
1253 fWrksInfo.GetSize(), fMaxTime, fInitTime, fMaxTime - fMergeTime,
1254 fEvtRateAvg, fEvtRateAvgMax, fMBRateAvg, fMBRateAvgMax);
1257 Printf(
" +++ %d workers were active during this query", fWrksInfo.GetSize());
1258 Printf(
" +++ Total query time: %f secs (init: %f secs, merge: %f secs)",
1259 fMaxTime, fInitTime, fMaxTime - fMergeTime);
1260 Printf(
" +++ Avg processing rates: %.4f evts/s, %.4f MB/s", fEvtRateAvg, fMBRateAvg);
1261 Printf(
" +++ Max processing rates: %.4f evts/s, %.4f MB/s", fEvtRateAvgMax, fMBRateAvgMax);
1264 if (!o.IsNull()) gSystem->RedirectOutput(0, 0, &rh);
1270 void TProofPerfAnalysis::FillFileInfo(Bool_t force)
1273 if (fFilesInfo.GetSize() > 0 && !force)
return;
1276 fFilesInfo.SetOwner(kTRUE);
1279 TList *fl =
new TList;
1282 TPerfEvent* pep = &pe;
1283 fTree->SetBranchAddress(
"PerfEvents",&pep);
1284 Long64_t entries = fTree->GetEntries();
1286 for (Long64_t k=0; k<entries; k++) {
1289 if (pe.fType == TVirtualPerfStats::kPacket) {
1290 TUrl uf(pe.fFileName);
1291 TString srv(uf.GetUrl());
1292 Int_t ifn = srv.Index(uf.GetFile());
1293 if (ifn != kNPOS) srv.Remove(ifn);
1295 fi = (TFileInfo *) fl->FindObject(uf.GetFile());
1297 fi =
new TFileInfo(uf.GetFile(), srv.Data());
1299 fi->fSizeP =
new TGraph(10);
1300 fi->fRateP =
new TGraph(10);
1301 fi->fRatePRemote =
new TGraph(10);
1302 fi->fMBRateP =
new TGraph(10);
1303 fi->fMBRatePRemote =
new TGraph(10);
1306 Float_t stop = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1307 Float_t start = stop - pe.fProcTime;
1308 if (fi->fPackets <= 0) {
1313 TUrl uw(pe.fSlaveName);
1316 fi->fSizeP->SetPoint(fi->fPackets, (Double_t) fi->fPackets, (Double_t) pe.fEventsProcessed);
1317 fi->fSizeAvg += pe.fEventsProcessed;
1318 if (pe.fEventsProcessed > fi->fSizeMax || fi->fSizeMax < 0.) fi->fSizeMax = pe.fEventsProcessed;
1319 if (pe.fEventsProcessed < fi->fSizeMin || fi->fSizeMin < 0.) fi->fSizeMin = pe.fEventsProcessed;
1322 Double_t tt = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1323 Double_t ert = pe.fEventsProcessed / pe.fProcTime ;
1324 Double_t brt = pe.fBytesRead / pe.fProcTime / 1024. / 1024. ;
1325 fi->fRateP->SetPoint(fi->fPackets, tt, ert);
1326 if (brt > 0.) fi->fMBRateP->SetPoint(fi->fPackets, tt, brt);
1327 if (!pe.fFileName.IsNull() && strcmp(uf.GetHostFQDN(), uw.GetHostFQDN())) {
1328 if (!(fi->fRWrkList.FindObject(pe.fSlave))) fi->fRWrkList.Add(
new TNamed(pe.fSlave, pe.fSlaveName));
1329 fi->fRatePRemote->SetPoint(fi->fRPackets, tt, ert);
1330 fi->fMBRatePRemote->SetPoint(fi->fRPackets, tt, brt);
1335 fi->fMBRateAvg += brt;
1336 if (brt > fi->fMBRateMax || fi->fMBRateMax < 0.) fi->fMBRateMax = brt;
1337 if (brt < fi->fMBRateMin || fi->fMBRateMin < 0.) fi->fMBRateMin = brt;
1341 TPackInfo *pi =
new TPackInfo(pe.fSlave, pe.fSlaveName, start, stop, pe.fEventsProcessed, brt);
1342 fi->fPackList.Add(pi);
1343 TWrkInfoFile *wif = 0;
1344 if (!(wif = (TWrkInfoFile *) fi->fWrkList.FindObject(pe.fSlave))) {
1345 wif =
new TWrkInfoFile(pe.fSlave, uf.GetFile());
1346 fi->fWrkList.Add(wif);
1348 wif->fPackets.Add(pi);
1352 if (pe.fProcTime > 0.) {
1353 Printf(
" +++ %s #:%d at:%fs lat:%fs proc:%fs evts:%lld bytes:%lld (rates:%f evt/s, %f MB/s)",
1354 fi->GetName(), fi->fPackets, fMaxTime - pe.fProcTime,
1355 pe.fLatency, pe.fProcTime, pe.fEventsProcessed, pe.fBytesRead,
1358 Printf(
" +++ %s #:%d at:%fs lat:%fs proc:%fs rate:-- evt/s (-- bytes/s)",
1359 fi->GetName(), fi->fPackets, fMaxTime, pe.fLatency, pe.fProcTime);
1362 }
else if (pe.fType == TVirtualPerfStats::kStart) {
1363 Float_t start = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1364 if (fDebug > 1) Printf(
" +++ %s Start: %f s", pe.fEvtNode.Data(), start);
1365 }
else if (pe.fType == TVirtualPerfStats::kStop) {
1366 Float_t stop = pe.fTimeStamp.GetSec() + 1e-9*pe.fTimeStamp.GetNanoSec();
1367 if (fDebug > 1) Printf(
" +++ %s Stop: %f s", pe.fEvtNode.Data(), stop);
1369 if (fDebug > 2) Printf(
" +++ Event type: %d", pe.fType);
1374 while ((fi = (TFileInfo *) nxf())) {
1377 fi->fRateP->Set(fi->fPackets);
1378 fi->fRatePRemote->Set(fi->fRPackets);
1379 fi->fMBRateP->Set(fi->fPackets);
1380 fi->fMBRatePRemote->Set(fi->fRPackets);
1382 fl->SetOwner(kFALSE);
1387 Printf(
" +++ %d files were processed during this query", fFilesInfo.GetSize());
1393 void TProofPerfAnalysis::SetDebug(Int_t d)
1402 void TProofPerfAnalysis::DoDraw(TObject *o, Option_t *opt,
const char *name)
1410 TDirectory *curdir = gDirectory;
1411 TFile *f = TFile::Open(fFileResult,
"UPDATE");
1412 if (f && !f->IsZombie()) {
1413 const char *n = (name && strlen(name) > 0) ? name : 0;
1418 gDirectory = curdir;
1428 Int_t TProofPerfAnalysis::SetSaveResult(
const char *file, Option_t *mode)
1433 fSaveResult = kFALSE;
1435 Printf(
"Drawn objects saving disabled");
1440 if (!fFileResult.IsNull() && fFileResult == file) {
1442 fSaveResult = kTRUE;
1447 fSaveResult = kFALSE;
1448 TDirectory *curdir = gDirectory;
1449 TFile *f = TFile::Open(file, mode);
1450 if (!f || f->IsZombie()) {
1453 Error(
"SetSaveResult",
"could not open file '%s' in mode '%s'", file, mode);
1454 gDirectory = curdir;
1459 gDirectory = curdir;
1462 fSaveResult = kTRUE;
1464 Printf(
"Drawn objects will be saved in file '%s'", file);
1471 void TProofPerfAnalysis::SetgDebug(Bool_t on)
1478 void TProofPerfAnalysis::EventDist()
1480 if (!fEvents || !fPackets) {
1481 Error(
"EventDist",
"distributions not initialized - do nothing");
1485 TCanvas *c1 =
new TCanvas(
"evtdist", GetCanvasTitle(
"Event distributions"),800,10,700,780);
1487 TPad *pad1 = (TPad *) c1->GetPad(1);
1489 fEvents->SetStats(kFALSE);
1491 TPad *pad2 = (TPad *) c1->GetPad(2);
1493 fPackets->SetStats(kFALSE);
1503 void TProofPerfAnalysis::RatePlot(
const char *wrks)
1505 Bool_t global = (wrks && !strcmp(wrks,
"global")) ? kTRUE : kFALSE;
1507 TH1F *hrt1 = 0, *hrt2 = 0;
1514 if ((o = gDirectory->FindObject(
"rt1")))
delete o;
1515 hrt1 =
new TH1F(
"rt1",
"Evt processing rate (evt/s)", 100, 0., fMaxTime);
1516 hrt1->SetMinimum(0.);
1517 hrt1->SetMaximum(1.05*fEvtRateMax);
1518 hrt1->SetStats(kFALSE);
1519 hrt1->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1520 if ((o = gDirectory->FindObject(
"rt2")))
delete o;
1521 hrt2 =
new TH1F(
"rt2",
"MB processing rate (MB/s)", 100, 0., fMaxTime);
1522 hrt2->SetMinimum(0.);
1523 hrt2->SetMaximum(1.05*fMBRateMax);
1524 hrt2->SetStats(kFALSE);
1525 hrt2->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1529 TCanvas *c1 =
new TCanvas(
"rates", GetCanvasTitle(
"Processing rates"), 800,10,700,780);
1531 TPad *pad1 = (TPad *) c1->GetPad(1);
1534 if (global) DoDraw(fEvtRateRun,
"SAME",
"EvtRateRun");
1535 TPad *pad2 = (TPad *) c1->GetPad(2);
1538 if (global) DoDraw(fMBRateRun,
"SAME",
"MBRateRun");
1548 if (!ww.IsNull() && ww !=
"*" && ww !=
"all") {
1551 while ((ww.Tokenize(w, from,
","))) {
1552 if (!wl) wl =
new THashList();
1553 wl->Add(
new TObjString(w.Data()));
1558 Int_t ci = 40, cir = 30, ic = 0;
1559 TIter nxw(&fWrksInfo);
1561 while ((wi = (TWrkInfo *) nxw())) {
1562 if (wl && !wl->FindObject(wi->GetName()))
continue;
1563 if (wi->fRateT && wi->fRateT->GetN() > 0) {
1564 wi->fRateT->SetNameTitle(wi->GetName(), wi->GetTitle());
1566 wi->fRateT->SetLineColor(ci);
1567 DoDraw(wi->fRateT,
"L", TString::Format(
"RateT-%s", wi->fRateT->GetName()));
1569 if (wi->fRateRemoteT && wi->fRateRemoteT->GetN() > 0) {
1570 wi->fRateRemoteT->SetNameTitle(wi->GetName(), wi->GetTitle());
1572 wi->fRateRemoteT->SetLineColor(cir);
1573 DoDraw(wi->fRateRemoteT,
"L", TString::Format(
"RateRemoteT-%s", wi->fRateRemoteT->GetName()));
1575 if (wi->fMBRateT && wi->fMBRateT->GetN() > 0) {
1576 wi->fMBRateT->SetNameTitle(wi->GetName(), wi->GetTitle());
1578 wi->fMBRateT->SetLineColor(ci);
1579 DoDraw(wi->fMBRateT,
"L", TString::Format(
"MBRateT-%s", wi->fMBRateT->GetName()));
1581 if (wi->fMBRateRemoteT && wi->fMBRateRemoteT->GetN() > 0) {
1582 wi->fMBRateRemoteT->SetNameTitle(wi->GetName(), wi->GetTitle());
1584 wi->fMBRateRemoteT->SetLineColor(cir);
1585 DoDraw(wi->fMBRateRemoteT,
"L", TString::Format(
"MBRateRemoteT-%s", wi->fMBRateRemoteT->GetName()));
1596 wl->SetOwner(kTRUE);
1605 void TProofPerfAnalysis::LatencyPlot(
const char *wrks)
1608 if ((o = gDirectory->FindObject(
"lt1")))
delete o;
1609 TH1F *hlt1 =
new TH1F(
"lt1",
"Packet retrieval latency", 100, 0., fMaxTime);
1610 hlt1->SetMinimum(0.);
1611 hlt1->SetMaximum(1.05*fLatencyMax);
1612 hlt1->SetStats(kFALSE);
1613 hlt1->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1614 hlt1->GetYaxis()->SetTitle(
"Latency (s)");
1617 TCanvas *c1 =
new TCanvas(
"latency", GetCanvasTitle(
"Packet Retrieval Latency"), 800,10,700,780);
1625 if (!ww.IsNull() && ww !=
"*" && ww !=
"all") {
1628 while ((ww.Tokenize(w, from,
","))) {
1629 if (!wl) wl =
new THashList();
1630 wl->Add(
new TObjString(w.Data()));
1635 Int_t ci = 40, ic = 0;
1636 TIter nxw(&fWrksInfo);
1638 while ((wi = (TWrkInfo *) nxw())) {
1639 if (wl && !wl->FindObject(wi->GetName()))
continue;
1640 if (wi->fLatencyT) {
1641 wi->fLatencyT->SetNameTitle(wi->GetName(), wi->GetTitle());
1642 wi->fLatencyT->SetLineColor(ci);
1643 DoDraw(wi->fLatencyT,
"L", TString::Format(
"LatencyT-%s", wi->fLatencyT->GetName()));
1653 wl->SetOwner(kTRUE);
1661 void TProofPerfAnalysis::FileProcPlot(
const char *fn,
const char *out)
1663 if (!fn || strlen(fn) <= 0) {
1664 Error(
"FileRatePlot",
"file name is mandatory!");
1668 TFileInfo *fi = (TFileInfo *) fFilesInfo.FindObject(fn);
1670 Error(
"FileRatePlot",
"TFileInfo object for '%s' not found!", fn);
1676 if (out && strlen(out) > 0) {
1677 if (!(fo = fopen(out,
"w"))) {
1678 Warning(
"FileRatePlot",
"problems creating '%s': logging to stdout", out);
1681 Printf(
" Details logged to %s", out);
1686 Int_t nbins = fi->fPackList.GetSize() * 2;
1687 Double_t *xraw =
new Double_t[nbins];
1690 TIter nxp(&(fi->fPackList));
1691 while ((pi = (TPackInfo *) nxp())) {
1693 xraw[jj++] = pi->fStart;
1694 xraw[jj++] = pi->fStop;
1696 Int_t *jidx =
new Int_t[nbins];
1697 memset(jidx, 0, nbins *
sizeof(Int_t));
1698 TMath::Sort(nbins, xraw, jidx, kFALSE);
1699 Double_t *xbins =
new Double_t[nbins];
1701 for (kk = 0; kk < nbins; kk++) {
1702 xbins[kk] = xraw[jidx[kk]];
1708 Int_t nbin = nbins - 1;
1710 if ((o = gDirectory->FindObject(
"rt1")))
delete o;
1711 TH1F *hrt1 =
new TH1F(
"rt1",
"Total processing rate (MB/s)", nbins - 1, xbins);
1712 hrt1->SetMinimum(0.);
1713 hrt1->SetStats(kFALSE);
1714 hrt1->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1715 if ((o = gDirectory->FindObject(
"rt2")))
delete o;
1716 TH1F *hrt2 =
new TH1F(
"rt2",
"Number of processing workers", nbins - 1, xbins);
1717 hrt2->SetMinimum(0.);
1718 hrt2->SetMaximum(1.2*fWrksInfo.GetSize());
1719 hrt2->SetStats(kFALSE);
1720 hrt2->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1721 if ((o = gDirectory->FindObject(
"rt3")))
delete o;
1722 TH1F *hrt3 =
new TH1F(
"rt3",
"Total processing events", nbins - 1, xbins);
1723 hrt3->SetMinimum(0.);
1724 hrt3->SetStats(kFALSE);
1725 hrt3->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1726 if ((o = gDirectory->FindObject(
"rt4")))
delete o;
1727 TH1F *hrt4 =
new TH1F(
"rt4",
"Weighted processing rate (MB/s)", nbins - 1, xbins);
1728 hrt4->SetMinimum(0.);
1729 hrt4->SetStats(kFALSE);
1730 hrt4->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1736 for (ii = 1; ii <= nbin; ii++) {
1737 Double_t mi = hrt1->GetBinLowEdge(ii);
1738 Double_t wd = hrt1->GetBinWidth(ii);
1739 Double_t mx = mi + wd;
1740 Double_t xx = hrt1->GetBinCenter(ii);
1741 fprintf(fo,
" Bin: %d/%d [%f, %f]\n", ii, nbin, mi, mx);
1745 while ((pi = (TPackInfo *) nxp())) {
1747 Double_t olap = pi->fStop - mi;
1748 if (pi->fStart > mi) olap = mx - pi->fStart;
1750 hrt1->Fill(xx, pi->fMBRate);
1752 hrt3->Fill(xx, pi->fSize);
1753 hrt4->Fill(xx, pi->fMBRate * pi->fSize);
1754 fprintf(fo,
" %d: %s \t%lld \tevts \t%f \tMB/s\n", kk++, pi->GetName(), pi->fSize, pi->fMBRate);
1758 if (fo != stdout) fclose(fo);
1761 TCanvas *c1 =
new TCanvas(
"rates", GetCanvasTitle(
"File processing info"), 800,10,700,780);
1763 TPad *pad1 = (TPad *) c1->GetPad(1);
1766 TPad *pad2 = (TPad *) c1->GetPad(2);
1769 TPad *pad4 = (TPad *) c1->GetPad(3);
1780 void TProofPerfAnalysis::FileRatePlot(
const char *fns)
1784 if ((o = gDirectory->FindObject(
"rt1")))
delete o;
1785 TH1F *hrt1 =
new TH1F(
"rt1",
"Event processing rate per packet (evt/s)", 100, 0., fMaxTime);
1786 hrt1->SetMinimum(0.);
1787 hrt1->SetMaximum(1.05*fEvtRateMax);
1788 hrt1->SetStats(kFALSE);
1789 hrt1->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1790 if ((o = gDirectory->FindObject(
"rt2")))
delete o;
1791 TH1F *hrt2 =
new TH1F(
"rt2",
"I/O processing rate per packet (MB/s)", 100, 0., fMaxTime);
1792 hrt2->SetMinimum(0.);
1793 hrt2->SetMaximum(1.05*fMBRateMax);
1794 hrt2->SetStats(kFALSE);
1795 hrt2->GetXaxis()->SetTitle(
"Query Processing Time (s)");
1798 TCanvas *c1 =
new TCanvas(
"rates", GetCanvasTitle(
"Processing rates"), 800,10,700,780);
1800 TPad *pad1 = (TPad *) c1->GetPad(1);
1803 TPad *pad2 = (TPad *) c1->GetPad(2);
1812 if (!fw.IsNull() && fw !=
"*" && fw !=
"all") {
1815 while ((fw.Tokenize(w, from,
","))) {
1816 if (!fl) fl =
new THashList();
1817 fl->Add(
new TObjString(w.Data()));
1822 Int_t ci = 40, cir = 30, ic = 0;
1823 TIter nxf(&fFilesInfo);
1825 while ((fi = (TFileInfo *) nxf())) {
1826 if (fl && !fl->FindObject(fi->GetName()))
continue;
1827 if (fi->fRateP && fi->fRateP->GetN() > 0) {
1828 fi->fRateP->SetNameTitle(fi->GetName(), fi->GetTitle());
1830 fi->fRateP->SetLineColor(ci);
1831 DoDraw(fi->fRateP,
"L", TString::Format(
"RateP-%d", ic));
1833 if (fi->fRatePRemote && fi->fRatePRemote->GetN() > 0) {
1834 fi->fRatePRemote->SetNameTitle(fi->GetName(), fi->GetTitle());
1836 fi->fRatePRemote->SetLineColor(cir);
1837 DoDraw(fi->fRatePRemote,
"L", TString::Format(
"RatePRemote-%d", ic));
1839 if (fi->fMBRateP && fi->fMBRateP->GetN() > 0) {
1840 fi->fMBRateP->SetNameTitle(fi->GetName(), fi->GetTitle());
1842 fi->fMBRateP->SetLineColor(ci);
1843 DoDraw(fi->fMBRateP,
"L", TString::Format(
"MBRateP-%d", ic));
1845 if (fi->fMBRatePRemote && fi->fMBRatePRemote->GetN() > 0) {
1846 fi->fMBRatePRemote->SetNameTitle(fi->GetName(), fi->GetTitle());
1848 fi->fMBRatePRemote->SetLineColor(cir);
1849 DoDraw(fi->fMBRatePRemote,
"L", TString::Format(
"MBRatePRemote-%d", ic));
1860 fl->SetOwner(kTRUE);