Skip to content
Snippets Groups Projects
Commit d9ccc6bc authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #11059: Added BudgetTimer around writing output to disk

parent 87f64063
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,18 @@ namespace LOFAR { ...@@ -42,6 +42,18 @@ namespace LOFAR {
void stop(); void stop();
// Internal class to do an automatic start/stop.
class StartStop {
public:
StartStop(BudgetTimer& timer) : itsTimer(timer) { itsTimer.start(); }
~StartStop() { itsTimer.stop(); }
private:
// Forbid copy.
StartStop (const StartStop&);
StartStop& operator= (StartStop&);
BudgetTimer& itsTimer;
};
private: private:
const double budget; const double budget;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <CoInterface/OutputTypes.h> #include <CoInterface/OutputTypes.h>
#include <CoInterface/Exceptions.h> #include <CoInterface/Exceptions.h>
#include <CoInterface/LTAFeedback.h> #include <CoInterface/LTAFeedback.h>
#include <CoInterface/BudgetTimer.h>
#if defined HAVE_AIPSPP #if defined HAVE_AIPSPP
#include <casa/Exceptions/Error.h> #include <casa/Exceptions/Error.h>
...@@ -71,6 +72,7 @@ namespace LOFAR ...@@ -71,6 +72,7 @@ namespace LOFAR
itsBlocksDropped(0), itsBlocksDropped(0),
itsNrExpectedBlocks(0), itsNrExpectedBlocks(0),
itsNextSequenceNumber(0), itsNextSequenceNumber(0),
itsBlockDuration(parset.settings.blockDuration()),
itsOutputPool(outputPool) itsOutputPool(outputPool)
{ {
} }
...@@ -97,7 +99,7 @@ namespace LOFAR ...@@ -97,7 +99,7 @@ namespace LOFAR
LOG_WARN_STR(itsLogPrefix << "Did not receive " << droppedBlocks << " blocks"); LOG_WARN_STR(itsLogPrefix << "Did not receive " << droppedBlocks << " blocks");
itsMdLogger.log(itsMdKeyPrefix + PN_COP_DROPPED + streamNrStr, itsMdLogger.log(itsMdKeyPrefix + PN_COP_DROPPED + streamNrStr,
itsBlocksDropped * static_cast<float>(itsParset.settings.blockDuration())); itsBlocksDropped * static_cast<float>(itsBlockDuration));
} }
itsNextSequenceNumber = data->sequenceNumber() + 1; itsNextSequenceNumber = data->sequenceNumber() + 1;
...@@ -106,15 +108,22 @@ namespace LOFAR ...@@ -106,15 +108,22 @@ namespace LOFAR
itsMdLogger.log(itsMdKeyPrefix + PN_COP_DROPPING + streamNrStr, itsMdLogger.log(itsMdKeyPrefix + PN_COP_DROPPING + streamNrStr,
droppedBlocks > 0); // logged too late if dropping: not anymore... droppedBlocks > 0); // logged too late if dropping: not anymore...
itsMdLogger.log(itsMdKeyPrefix + PN_COP_WRITTEN + streamNrStr, itsMdLogger.log(itsMdKeyPrefix + PN_COP_WRITTEN + streamNrStr,
itsBlocksWritten * static_cast<float>(itsParset.settings.blockDuration())); itsBlocksWritten * static_cast<float>(itsBlockDuration));
} }
template<typename T> void OutputThread<T>::doWork() template<typename T> void OutputThread<T>::doWork()
{ {
BudgetTimer writeTimer(
"writeOutput",
itsBlockDuration,
true, true);
for (SmartPtr<T> data; (data = itsOutputPool.filled.remove()) != 0; itsOutputPool.free.append(data)) { for (SmartPtr<T> data; (data = itsOutputPool.filled.remove()) != 0; itsOutputPool.free.append(data)) {
if (itsParset.settings.realTime) { if (itsParset.settings.realTime) {
try { try {
BudgetTimer::StartStop ss(writeTimer);
itsWriter->write(data); itsWriter->write(data);
} catch (SystemCallException &ex) { } catch (SystemCallException &ex) {
LOG_WARN_STR(itsLogPrefix << "OutputThread caught non-fatal exception: " << ex.what()); LOG_WARN_STR(itsLogPrefix << "OutputThread caught non-fatal exception: " << ex.what());
...@@ -262,6 +271,7 @@ namespace LOFAR ...@@ -262,6 +271,7 @@ namespace LOFAR
logPrefix + "[SubbandOutputThread] ", logPrefix + "[SubbandOutputThread] ",
targetDirectory) targetDirectory)
{ {
itsBlockDuration = parset.settings.correlator.integrationTime();
} }
......
...@@ -97,6 +97,7 @@ namespace LOFAR ...@@ -97,6 +97,7 @@ namespace LOFAR
size_t itsBlocksWritten, itsBlocksDropped; size_t itsBlocksWritten, itsBlocksDropped;
size_t itsNrExpectedBlocks; size_t itsNrExpectedBlocks;
size_t itsNextSequenceNumber; size_t itsNextSequenceNumber;
double itsBlockDuration; // seconds
Pool<T> &itsOutputPool; Pool<T> &itsOutputPool;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment