Skip to content

Commit

Permalink
Issue microsoft#117: Implement more robust latency information of thr…
Browse files Browse the repository at this point in the history
…ead groups.

. Added TargetID to make it possible to connect a <Results>/<Target> to it's original <Profile>/<Target> in multi-threaded test Profiles.
. Added latency totals and grouping of TargeID's.
  • Loading branch information
Centis Biks committed Sep 3, 2019
1 parent 3d16def commit f477f50
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
4 changes: 3 additions & 1 deletion CmdLineParser/CmdLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,16 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
// create targets
vector<Target> vTargets;
int iFirstFile = -1;
int iTargetID = 0;
for (int i = 1; i < argc; i++)
{
if (argv[i][0] != '-' && argv[i][0] != '/')
{
iFirstFile = i;
Target target;
Target target(iTargetID);
target.SetPath(argv[i]);
vTargets.push_back(target);
iTargetID++;
}
}

Expand Down
21 changes: 11 additions & 10 deletions Common/Histogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ using HistogramBucketList = std::vector<float>;
using HistogramBucketListPtr = std::shared_ptr<HistogramBucketList>;
using ConstHistogramBucketListPtr = std::shared_ptr<const HistogramBucketList>;

/****************************************************************************************************************************************************
CBTODO: Histograms consumers should use a specific type, like PerfTimer, rather than float/double to minimze conversion errors.
****************************************************************************************************************************************************/
template<typename T>
class Histogram
{
Expand Down Expand Up @@ -122,12 +125,11 @@ class Histogram
{
T value = std::numeric_limits<T>::max();

for (auto i : _data)
auto sortedData = _GetSortedData();
auto iter = sortedData->begin();
if (iter != sortedData->end())
{
if (i.first < value)
{
value = i.first;
}
value = iter->first;
}

return value;
Expand All @@ -137,12 +139,11 @@ class Histogram
{
T value = std::numeric_limits<T>::min();

for (auto i : _data)
auto sortedData = _GetSortedData();
auto iter = sortedData->rbegin();
if (iter != sortedData->rend())
{
if (i.first > value)
{
value = i.first;
}
value = iter->first;
}

return value;
Expand Down
1 change: 1 addition & 0 deletions IORequestGenerator/IORequestGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ DWORD WINAPI threadFunc(LPVOID cookie)
p->pResults->vTargetResults.resize(p->vTargets.size());
for (size_t i = 0; i < p->vullFileSizes.size(); i++)
{
p->pResults->vTargetResults[i].iTargetID = p->vTargets[i].GetTargetID();
p->pResults->vTargetResults[i].sPath = p->vTargets[i].GetPath();
p->pResults->vTargetResults[i].ullFileSize = p->vullFileSizes[i];
if(fCalculateIopsStdDev)
Expand Down
3 changes: 2 additions & 1 deletion XmlProfileParser/XmlProfileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ HRESULT XmlProfileParser::_ParseTargets(IXMLDOMNode *pXmlNode, TimeSpan *pTimeSp
hr = spNodeList->get_item(i, &spNode);
if (SUCCEEDED(hr))
{
Target target;
Target target(i);
_ParseTarget(spNode, &target);
pTimeSpan->AddTarget(target);
}
Expand Down Expand Up @@ -1294,6 +1294,7 @@ HRESULT XmlProfileParser::_GetProgress(IXMLDOMDocument2 *pXmlDoc, DWORD *pdwProg
{
return _GetDWORD(pXmlDoc, "//Profile/Progress", pdwProgress);
}

HRESULT XmlProfileParser::_GetHighPrecisionOutput(IXMLDOMDocument2* pXmlDoc, bool* pfHighPrecisionOutput)
{
return _GetBool(pXmlDoc, "//Profile/HighPrecisionOutput", pfHighPrecisionOutput);
Expand Down
31 changes: 27 additions & 4 deletions XmlResultParser/XmlResultParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ void XmlResultParser::_OutputTargetResults(const TargetResults& results,
// TODO: results.readBucketizer;
// TODO: results.writeBucketizer;

_OutputValue("Path", results.sPath.c_str());
_OutputValue("Id", results.iTargetID);
_OutputValue("Path", results.sPath);
_OutputValue("BytesCount", results.ullBytesCount);
_OutputValue("FileSize", results.ullFileSize);
_OutputValue("IOCount", results.ullIOCount);
Expand Down Expand Up @@ -179,6 +180,8 @@ void XmlResultParser::_OutputLatencySummary(const Histogram<float>& latencyHisto
_OutputValue(latencyHistogramName + "LatencyHistogramBins", latencyHistogram.GetBucketCount());
_OutputLatencyInMilliseconds(latencyHistogramName + "Average", latencyHistogram.GetAvg());
_OutputLatencyInMilliseconds(latencyHistogramName + "Stdev", latencyHistogram.GetStandardDeviation());
_OutputLatencyInMilliseconds(latencyHistogramName + "Min", latencyHistogram.GetMin());
_OutputLatencyInMilliseconds(latencyHistogramName + "Max", latencyHistogram.GetMax());
}

void XmlResultParser::_OutputTargetIops(const IoBucketizer& readBucketizer,
Expand Down Expand Up @@ -635,6 +638,8 @@ string XmlResultParser::ParseResults(Profile& profile,

if (timeSpan.GetMeasureLatency())
{
std::map<int, std::shared_ptr<TargetIDGroup>> targetIDGroups;

Histogram<float> readLatencyHistogram;
Histogram<float> writeLatencyHistogram;
Histogram<float> totalLatencyHistogram;
Expand All @@ -643,6 +648,16 @@ string XmlResultParser::ParseResults(Profile& profile,
{
for (const auto& target : thread.vTargetResults)
{
auto it = targetIDGroups.find(target.iTargetID);
if (it != targetIDGroups.end())
{
(*it).second->Add(target);
}
else
{
targetIDGroups[target.iTargetID] = std::make_shared<TargetIDGroup>(target);
}

readLatencyHistogram.Merge(target.readLatencyHistogram);
writeLatencyHistogram.Merge(target.writeLatencyHistogram);
totalLatencyHistogram.Merge(target.writeLatencyHistogram);
Expand All @@ -652,10 +667,18 @@ string XmlResultParser::ParseResults(Profile& profile,

_OutputLatencySummary(readLatencyHistogram, writeLatencyHistogram, totalLatencyHistogram, profile.GetHistogramBucketList(), fTime);

ConstHistogramBucketListPtr histogramBucketList = profile.GetHistogramBucketList();
if (histogramBucketList)
if (targetIDGroups.size() > 1)
{
_OutputLatencyBuckets(readLatencyHistogram, writeLatencyHistogram, totalLatencyHistogram, histogramBucketList, fTime);
for (const auto& targetIDGroup : targetIDGroups)
{
if (targetIDGroup.second->GetCount() > 1)
{
_Output("<TargetIDGroup>\n");
_OutputTargetResults(*(targetIDGroup.second->GetTargetResults()), timeSpan.GetMeasureLatency(), profile.GetHistogramBucketList(), fTime,
timeSpan.GetCalculateIopsStdDev(), timeSpan.GetIoBucketDurationInMilliseconds());
_Output("</TargetIDGroup>\n");
}
}
}
}

Expand Down

0 comments on commit f477f50

Please sign in to comment.