*/
#include "AliHLTCompStatCollector.h"
+#include "TFile.h"
#include "TStopwatch.h"
#include "TH1F.h"
#include "TH2F.h"
fpCTimeArray(NULL),
fpInputBlockCountArray(NULL),
fpTotalInputSizeArray(NULL),
+ fpNormalizedInputSizeArray(NULL),
fpOutputBlockCountArray(NULL),
fpTotalOutputSizeArray(NULL)
+ , fpInputOutputRatioArray(NULL)
+ , fpNormalizedInputOutputRatioArray(NULL)
+ , fpComponentCycleTimeArray(NULL)
+ , fpEventTypeArray(NULL)
+ , fpEventCountArray(NULL)
+ , fSizeEstimator(1000)
+ , fMode(kPublishObjects)
+ , fFileName()
+ , fFile(NULL)
+ , fLastTime(time(NULL))
+ , fPeriod(0)
+ , fEventModulo(0)
{
// see header file for class documentation
// or
void AliHLTCompStatCollector::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
{
// see header file for class documentation
- constBase=1000;
+ constBase=fSizeEstimator;
inputMultiplier=100.0;
}
argument=argv[i];
if (argument.IsNull()) continue;
- // -array-size
- if (argument.CompareTo("-array-size")==0) {
+ // -file
+ if (argument.CompareTo("-file")==0) {
if ((bMissingParam=(++i>=argc))) break;
- TString param=argv[argc];
+ fFileName=argv[i];
+ fMode|=kSaveObjects;
+
+ // -modulo
+ } else if (argument.CompareTo("-modulo")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ TString param=argv[i];
+ if (param.IsDigit()) {
+ fEventModulo=param.Atoi();
+ } else {
+ HLTError("expecting number as parameter for option %s", argument.Data());
+ iResult=-EINVAL;
+ }
+
+ // -period
+ } else if (argument.CompareTo("-period")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ TString param=argv[i];
+ if (param.IsDigit()) {
+ fPeriod=param.Atoi();
+ } else {
+ HLTError("expecting number as parameter for option %s", argument.Data());
+ iResult=-EINVAL;
+ }
+
+ // -publish
+ } else if (argument.CompareTo("-publish")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ TString param=argv[i];
+ if (param.IsDigit()) {
+ if (param.Atoi()==1) fMode|=kPublishObjects;
+ else if (param.Atoi()==0) fMode&=~kPublishObjects;
+ else {
+ HLTError("expecting 0 or 1 as parameter for option %s", argument.Data());
+ iResult=-EINVAL;
+ }
+ } else {
+ HLTError("expecting number as parameter for option %s", argument.Data());
+ iResult=-EINVAL;
+ }
+
+ // -arraysize
+ } else if (argument.CompareTo("-arraysize")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ TString param=argv[i];
if (param.IsDigit()) {
fArraySize=param.Atoi();
} else {
- HLTError("expecting number as parameter for option '-array-size'");
+ HLTError("expecting number as parameter for option %s", argument.Data());
iResult=-EINVAL;
}
} else {
+ HLTError("unknown argument %s", argument.Data());
iResult=-EINVAL;
}
}
fpCTimeArray=new UInt_t[fArraySize];
fpInputBlockCountArray=new UInt_t[fArraySize];
fpTotalInputSizeArray=new UInt_t[fArraySize];
+ fpNormalizedInputSizeArray=new UInt_t[fArraySize];
fpOutputBlockCountArray=new UInt_t[fArraySize];
fpTotalOutputSizeArray=new UInt_t[fArraySize];
+ fpInputOutputRatioArray=new UInt_t[fArraySize];
+ fpNormalizedInputOutputRatioArray=new UInt_t[fArraySize];
+ fpComponentCycleTimeArray=new UInt_t[fArraySize];
+ fpEventTypeArray=new UInt_t[fArraySize];
+ fpEventCountArray=new UInt_t[fArraySize];
fpStatTree=new TTree("CompStat", "HLT component statistics");
if (fpStatTree) {
fpStatTree->Branch("CTime", fpCTimeArray, "CTime[nofSets]/i");
fpStatTree->Branch("InputBlockCount", fpInputBlockCountArray, "InputBlockCount[nofSets]/i");
fpStatTree->Branch("TotalInputSize", fpTotalInputSizeArray, "TotalInputSize[nofSets]/i");
+ fpStatTree->Branch("NormalizedInputSize", fpNormalizedInputSizeArray, "NormalizedInputSize[nofSets]/i");
fpStatTree->Branch("OutputBlockCount", fpOutputBlockCountArray, "OutputBlockCount[nofSets]/i");
fpStatTree->Branch("TotalOutputSize", fpTotalOutputSizeArray, "TotalOutputSize[nofSets]/i");
+ fpStatTree->Branch("InputOutputRatio", fpInputOutputRatioArray, "InputOutputRatio[nofSets]/i");
+ fpStatTree->Branch("NormalizedInputOutputRatio", fpNormalizedInputOutputRatioArray, "NormalizedInputOutputRatio[nofSets]/i");
+ fpStatTree->Branch("ComponentCycleTime",fpComponentCycleTimeArray, "ComponentCycleTime[nofSets]/i");
+ fpStatTree->Branch("EventType",fpEventTypeArray, "EventType[nofSets]/i");
+ fpStatTree->Branch("EventCount",fpEventCountArray, "EventCount[nofSets]/i");
}
}
+
+ if (!fFileName.empty()) {
+ fFile=new TFile(fFileName.c_str(), "RECREATE");
+ }
return iResult;
}
// see header file for class documentation
ClearAll();
+ if (fFile) {
+ fFile->Close();
+ delete fFile;
+ fFile=NULL;
+ }
return 0;
}
bool bEmbeddedTree=false;
bool bFolderCreated=false;
- if (bFolderCreated=(fpFolder==NULL)) {
+ if ((bFolderCreated=(fpFolder==NULL))) {
fpFolder=new TFolder(HLTSTAT_FOLDER_NAME, HLTSTAT_FOLDER_DESC);
if (bEmbeddedTree) fpFolder->Add(fpStatTree);
}
if (parentFolder) {
TIter entries(parentFolder->GetListOfFolders());
while (TObject* entry=entries.Next())
- if (entry) HLTDebug(" searching %s in %s: %s", idstr.Data(), (*consumer)->GetName(), entry->GetName());
-
+ if (entry) {
+ Bool_t foo; foo=kTRUE;// only to avoid warning in non-debug compile
+ HLTDebug(" searching %s in %s: %s", idstr.Data(), (*consumer)->GetName(), entry->GetName());
+ }
TObject* parent=parentFolder->FindObjectAny(idstr);
if (parent) {
parentFolder->Add(*publisher);
pBlock && iResult>=0;
pBlock=GetNextInputBlock(), blockNo++) {
unsigned int current=fPosition;
- iResult=FillVariablesSorted(pBlock->fPtr, pBlock->fSize);
+ iResult=FillVariablesSorted(pBlock->fPtr, pBlock->fSize, eventType);
for (; current<fPosition; current++) {
fpSpecArray[current]=pBlock->fSpecification;
fpBlockNoArray[current]=blockNo;
iResult=1;
}
- if (iResult>0) {
+ int totalOutputSize=0;
+ if (iResult>0 && eventType) {
fNofSets=fPosition;
fpStatTree->Fill();
- if (!bEmbeddedTree)
- iResult=PushBack(fpStatTree, kAliHLTDataTypeTTree|kAliHLTDataOriginOut);
// init the timer for the next cycle
if (!fpTimer) fpTimer=new TStopwatch;
}
}
- if (iResult>=0 /*&& eventType==gkAliEventTypeEndOfRun*/) {
- PushBack(fpFolder, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
+ if (eventType==gkAliEventTypeEndOfRun ||
+ (iResult>=0 && CheckPeriod())) {
+
+ // publish objects to component output
+ if ((fMode&kPublishObjects)!=0) {
+ if (!bEmbeddedTree) {
+ iResult=PushBack(fpStatTree, kAliHLTDataTypeTTree|kAliHLTDataOriginOut);
+ totalOutputSize+=GetLastObjectSize();
+ }
+ iResult=PushBack(fpFolder, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
+ totalOutputSize+=GetLastObjectSize();
+ }
+
+ // save objects to file
+ if ((fMode&kSaveObjects)!=0 && fFile!=NULL) {
+ HLTDebug("saving objects to file %s", fFileName.c_str());
+ fFile->cd();
+ if (!bEmbeddedTree) {
+ fpStatTree->Write("", TObject::kOverwrite);
+ }
+ fpFolder->Write("", TObject::kOverwrite);
+ }
+ }
+
+ if (iResult==-ENOSPC) {
+ fSizeEstimator+=totalOutputSize;
}
if (iResult>0) iResult=0;
memset(fpCTimeArray, 0, sizeof(UInt_t)*fArraySize);
memset(fpInputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
memset(fpTotalInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpNormalizedInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
memset(fpOutputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
memset(fpTotalOutputSizeArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpNormalizedInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpComponentCycleTimeArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpEventTypeArray, 0, sizeof(UInt_t)*fArraySize);
+ memset(fpEventCountArray, 0, sizeof(UInt_t)*fArraySize);
}
-int AliHLTCompStatCollector::FillVariablesSorted(void* ptr, int size)
+int AliHLTCompStatCollector::FillVariablesSorted(void* ptr, int size, AliHLTUInt32_t eventType)
{
// see header file for class documentation
int iResult=0;
if (size%sizeof(AliHLTComponentStatistics)) {
+ // older or invalid structure
HLTError("data block is not aligned to the size of the AliHLTComponentStatistics struct");
return -EINVAL;
}
+
AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(ptr);
UInt_t nofStats=size/sizeof(AliHLTComponentStatistics);
vector<int> indexList;
fpCTimeArray[i]=pStat[*element].fCTime;
fpInputBlockCountArray[i]=pStat[*element].fInputBlockCount;
fpTotalInputSizeArray[i]=pStat[*element].fTotalInputSize;
+ fpNormalizedInputSizeArray[i]=pStat[*element].fTotalInputSize;
+ if (pStat[*element].fInputBlockCount>0)
+ fpNormalizedInputSizeArray[i]/=pStat[*element].fInputBlockCount;
fpOutputBlockCountArray[i]=pStat[*element].fOutputBlockCount;
fpTotalOutputSizeArray[i]=pStat[*element].fTotalOutputSize;
+ if (pStat[*element].fTotalOutputSize>0)
+ fpInputOutputRatioArray[i]=pStat[*element].fTotalInputSize/pStat[*element].fTotalOutputSize;
+ if (pStat[*element].fInputBlockCount>0)
+ fpNormalizedInputOutputRatioArray[i]=fpInputOutputRatioArray[i]*pStat[*element].fOutputBlockCount/pStat[*element].fInputBlockCount;
+ fpComponentCycleTimeArray[i]=pStat[*element].fComponentCycleTime;
+ fpEventTypeArray[i]=eventType;
+ fpEventCountArray[i]=GetEventCount();
+ } else {
+ // TODO: dynamically grow arrays with placement new
}
}
if (fpCTimeArray) delete fpCTimeArray; fpCTimeArray=NULL;
if (fpInputBlockCountArray) delete fpInputBlockCountArray; fpInputBlockCountArray=NULL;
if (fpTotalInputSizeArray) delete fpTotalInputSizeArray; fpTotalInputSizeArray=NULL;
+ if (fpNormalizedInputSizeArray) delete fpNormalizedInputSizeArray; fpNormalizedInputSizeArray=NULL;
if (fpOutputBlockCountArray) delete fpOutputBlockCountArray; fpOutputBlockCountArray=NULL;
if (fpTotalOutputSizeArray) delete fpTotalOutputSizeArray; fpTotalOutputSizeArray=NULL;
+ if (fpInputOutputRatioArray) delete fpInputOutputRatioArray; fpInputOutputRatioArray=NULL;
+ if (fpNormalizedInputOutputRatioArray) delete fpNormalizedInputOutputRatioArray; fpNormalizedInputOutputRatioArray=NULL;
+ if (fpComponentCycleTimeArray) delete fpComponentCycleTimeArray; fpComponentCycleTimeArray=NULL;
+ if (fpEventTypeArray) delete fpEventTypeArray; fpEventTypeArray=NULL;
+ if (fpEventCountArray) delete fpEventCountArray; fpEventCountArray=NULL;
}
int AliHLTCompStatCollector::RemoveRecurrence(TFolder* pRoot) const
return iResult;
}
+
+bool AliHLTCompStatCollector::CheckPeriod(bool bUpdate)
+{
+ // see header file for class documentation
+ bool result=true;
+ if (fEventModulo>0) {
+ if ((result=((GetEventCount()+1)%fEventModulo)==0)) {
+ return true;
+ }
+ }
+ if (fPeriod>0) {
+ if ((result=((difftime(time(NULL), fLastTime)>(double)fPeriod))) &&
+ bUpdate) {
+ fLastTime=time(NULL);
+ }
+ }
+ return result;
+}