Commit 8970b942 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Include zgy file name in telemetry output.

parent a32ac9ae
......@@ -147,7 +147,7 @@ LocalFileLinux::xx_make_instance(const std::string& filename, OpenMode mode, con
if (filename.find("://") == std::string::npos) {
auto file = std::shared_ptr<FileADT>(new LocalFileLinux(filename, mode, iocontext));
// This is a no-op unless enabled by enviroment variables
file = FileWithPerformanceLogger::inject(file);
file = FileWithPerformanceLogger::inject(file, filename);
// This is for ad-hoc testing ONLY. Enable the parallelizer as the
// windows reader does. On Linux (i.e. in this file) it gives
......
......@@ -30,10 +30,10 @@ namespace InternalZGY {
}
#endif
FileWithPerformanceLogger::FileWithPerformanceLogger(std::shared_ptr<FileADT> relay, const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval)
FileWithPerformanceLogger::FileWithPerformanceLogger(std::shared_ptr<FileADT> relay, const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval, const std::string& srcname)
: FileRelay(relay)
, _recorder(new PerformanceLogger
(outname, chunksize, hist_bincount, hist_min, hist_max, interval))
(outname, chunksize, hist_bincount, hist_min, hist_max, interval, srcname))
{
}
......@@ -104,7 +104,7 @@ FileWithPerformanceLogger::xx_close()
* and can be fine tuned by MEASURE_BINS and MEASURE_TIME.
*/
std::shared_ptr<FileADT>
FileWithPerformanceLogger::inject(std::shared_ptr<FileADT> file)
FileWithPerformanceLogger::inject(std::shared_ptr<FileADT> file, const std::string& srcname)
{
int target = Environment::getNumericEnv("OPENZGY_MEASURE_KB", 0);
if (target != 0) {
......@@ -113,7 +113,7 @@ FileWithPerformanceLogger::inject(std::shared_ptr<FileADT> file)
int interval = Environment::getNumericEnv("OPENZGY_MEASURE_INTERVAL", 0);
std::string filename = Environment::getStringEnv("OPENZGY_MEASURE_LOGFILE");
std::shared_ptr<std::ostream> out;
file = std::shared_ptr<FileADT>(new FileWithPerformanceLogger(file, filename, target*1024, bincount, 0.0, maxtime, interval));
file = std::shared_ptr<FileADT>(new FileWithPerformanceLogger(file, filename, target*1024, bincount, 0.0, maxtime, interval, srcname));
}
return file;
}
......
......@@ -50,14 +50,14 @@ private:
FileWithPerformanceLogger& operator=(FileWithPerformanceLogger&&) = delete;
public:
explicit FileWithPerformanceLogger(std::shared_ptr<FileADT> relay, const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval);
explicit FileWithPerformanceLogger(std::shared_ptr<FileADT> relay, const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval, const std::string& srcname);
virtual ~FileWithPerformanceLogger();
// Intercept
virtual void xx_read(void *data, std::int64_t offset, std::int64_t size, UsageHint usagehint) override;
virtual void xx_readv(const ReadList& requests, bool parallel_ok, bool immutable_ok, bool transient_ok, UsageHint usagehint) override;
virtual void xx_close() override;
static std::shared_ptr<FileADT> inject(std::shared_ptr<FileADT> file);
static std::shared_ptr<FileADT> inject(std::shared_ptr<FileADT> file, const std::string& srcname);
};
} // namespace
......@@ -1218,7 +1218,7 @@ SeismicStoreFile::xx_make_instance(const std::string& filename, OpenMode mode, c
auto file = std::shared_ptr<FileADT>(new SeismicStoreFile(filename, mode, iocontext));
// This is a no-op unless enabled by enviroment variables.
// Note, this might have been injected after the FileParallelizer instead.
file = FileWithPerformanceLogger::inject(file);
file = FileWithPerformanceLogger::inject(file, filename);
// Improve multi-threading of decompress and copy-out.
auto context = dynamic_cast<const SeismicStoreIOContext*>(iocontext);
......
......@@ -33,7 +33,7 @@ namespace InternalZGY {
std::atomic<int> PerformanceLogger::_last_id{0};
PerformanceLogger::PerformanceLogger(const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval)
PerformanceLogger::PerformanceLogger(const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval, const std::string& srcname)
: _outfile()
, _chunksize(chunksize)
, _mutex()
......@@ -52,6 +52,7 @@ PerformanceLogger::PerformanceLogger(const std::string& outname, std::int64_t ch
, _sumbytes(0)
, _first(true)
, _id(0)
, _srcname(srcname)
{
_id = 1 + _last_id.fetch_add(1);
std::string name(outname);
......@@ -145,16 +146,17 @@ PerformanceLogger::dumpLatency(bool clear)
const double binwidth = (_histmax - _histmin) / (nbins - 1);
ss << "CSV1,ID,Samplecount,Histogram min,Histogram max"
<< ",Statistic min,Statistic max,Statistic average,END\n"
<< ",Statistic min,Statistic max,Statistic average,Filename,END\n"
<< "CSV2," << _id << "," << _nsamples
<< "," << _histmin << "," << _histmax
<< "," << _statmin << "," << _statmax
<< "," << _statsum / _nsamples
<< ",\"" << _srcname << "\""
<< ",END\n";
// Dump center value of each histogram bin.
// Note that CSV3, CSV4, CSV5 can all be computed in a
// spreadsheet using a simple formula. Bit I'd like to
// spreadsheet using a simple formula. But I'd like to
// have an (almost) single-click way of making the graph.
ss << "CSV3," << _id << ",Latency";
for (int ii=0; ii<nbins; ++ii)
......@@ -200,7 +202,7 @@ PerformanceLogger::dumpThroughput(bool clear)
std::lock_guard<std::mutex> lk(_mutex);
std::stringstream ss;
if (_first) {
ss << "CSV0,Timestamp,ID,Data(MB),Time(sec),Speed(MB/s),Readcount,Mean latency(ms),END\n";
ss << "CSV0,Timestamp,ID,Data(MB),Time(sec),Speed(MB/s),Readcount,Mean latency(ms),Filename,END\n";
_first = false;
}
if (_sumtimerbeg < _sumtimerend && _sumbytes > 0) {
......@@ -221,6 +223,7 @@ PerformanceLogger::dumpThroughput(bool clear)
<< "," << std::setprecision(0)
<< (_sumtimer->getCount() == 0 ? 0 :
1000.0 * _sumtimer->getTotal() / _sumtimer->getCount())
<< ",\"" << _srcname << "\""
<< ",END\n";
}
if (clear) {
......
......@@ -80,6 +80,7 @@ private:
std::int64_t _sumbytes;
bool _first;
int _id;
const std::string _srcname;
static std::atomic<int> _last_id;
PerformanceLogger(const PerformanceLogger&) = delete;
......@@ -88,7 +89,7 @@ private:
PerformanceLogger& operator=(PerformanceLogger&&) = delete;
public:
explicit PerformanceLogger(const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval);
explicit PerformanceLogger(const std::string& outname, std::int64_t chunksize, int hist_bincount, double hist_min, double hist_max, int interval, const std::string& srcname);
virtual ~PerformanceLogger();
bool logThisSize(std::int64_t size);
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment