Skip to content
Snippets Groups Projects
Commit 18197473 authored by Eric Cano's avatar Eric Cano
Browse files

Added timing logs to Scheduler::getNextMount().

parent d12d5a03
No related branches found
No related tags found
No related merge requests found
...@@ -469,9 +469,24 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -469,9 +469,24 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
// Many steps for this logic are not specific for the database and are hence // Many steps for this logic are not specific for the database and are hence
// implemented in the scheduler itself. // implemented in the scheduler itself.
// First, get the mount-related info from the DB // First, get the mount-related info from the DB
utils::Timer timer;
double getMountInfoTime = 0;
double queueTrimingTime = 0;
double getTapeInfoTime = 0;
double candidateSortingTime = 0;
double getTapeForWriteTime = 0;
double decisionTime = 0;
double mountCreationTime = 0;
double driveStatusSetTime = 0;
double schedulerDbTime = 0;
double catalogueTime = 0;
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> mountInfo; std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> mountInfo;
mountInfo = m_db.getMountInfo(lc); mountInfo = m_db.getMountInfo(lc);
if (mountInfo->queueTrimRequired) m_db.trimEmptyQueues(lc); getMountInfoTime = timer.secs(utils::Timer::resetCounter);
if (mountInfo->queueTrimRequired) {
m_db.trimEmptyQueues(lc);
queueTrimingTime = timer.secs(utils::Timer::resetCounter);
}
__attribute__((unused)) SchedulerDatabase::TapeMountDecisionInfo & debugMountInfo = *mountInfo; __attribute__((unused)) SchedulerDatabase::TapeMountDecisionInfo & debugMountInfo = *mountInfo;
// The library information is not know for the tapes involved in retrieves. We // The library information is not know for the tapes involved in retrieves. We
...@@ -483,6 +498,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -483,6 +498,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
} }
if (tapeSet.size()) { if (tapeSet.size()) {
auto tapesInfo=m_catalogue.getTapesByVid(tapeSet); auto tapesInfo=m_catalogue.getTapesByVid(tapeSet);
getTapeInfoTime = timer.secs(utils::Timer::resetCounter);
for (auto &m:mountInfo->potentialMounts) { for (auto &m:mountInfo->potentialMounts) {
if (m.type==common::dataStructures::MountType::Retrieve) { if (m.type==common::dataStructures::MountType::Retrieve) {
m.logicalLibrary=tapesInfo[m.vid].logicalLibraryName; m.logicalLibrary=tapesInfo[m.vid].logicalLibraryName;
...@@ -591,6 +607,8 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -591,6 +607,8 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
std::sort(mountInfo->potentialMounts.begin(), mountInfo->potentialMounts.end()); std::sort(mountInfo->potentialMounts.begin(), mountInfo->potentialMounts.end());
std::reverse(mountInfo->potentialMounts.begin(), mountInfo->potentialMounts.end()); std::reverse(mountInfo->potentialMounts.begin(), mountInfo->potentialMounts.end());
candidateSortingTime = timer.secs(utils::Timer::resetCounter);
// Find out if we have any potential archive mount in the list. If so, get the // Find out if we have any potential archive mount in the list. If so, get the
// list of tapes from the catalogue. // list of tapes from the catalogue.
std::list<catalogue::TapeForWriting> tapeList; std::list<catalogue::TapeForWriting> tapeList;
...@@ -598,6 +616,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -598,6 +616,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
mountInfo->potentialMounts.cbegin(), mountInfo->potentialMounts.cend(), mountInfo->potentialMounts.cbegin(), mountInfo->potentialMounts.cend(),
[](decltype(*mountInfo->potentialMounts.cbegin())& m){ return m.type == common::dataStructures::MountType::Archive; } )) { [](decltype(*mountInfo->potentialMounts.cbegin())& m){ return m.type == common::dataStructures::MountType::Archive; } )) {
tapeList = m_catalogue.getTapesForWriting(logicalLibraryName); tapeList = m_catalogue.getTapesForWriting(logicalLibraryName);
getTapeForWriteTime = timer.secs(utils::Timer::resetCounter);
} }
// Remove from the tape list the ones already or soon to be mounted // Remove from the tape list the ones already or soon to be mounted
...@@ -626,18 +645,23 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -626,18 +645,23 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
std::unique_ptr<ArchiveMount> internalRet(new ArchiveMount(m_catalogue)); std::unique_ptr<ArchiveMount> internalRet(new ArchiveMount(m_catalogue));
// Get the db side of the session // Get the db side of the session
try { try {
decisionTime += timer.secs(utils::Timer::resetCounter);
internalRet->m_dbMount.reset(mountInfo->createArchiveMount(t, internalRet->m_dbMount.reset(mountInfo->createArchiveMount(t,
driveName, driveName,
logicalLibraryName, logicalLibraryName,
utils::getShortHostname(), utils::getShortHostname(),
time(NULL)).release()); time(NULL)).release());
mountCreationTime += timer.secs(utils::Timer::resetCounter);
internalRet->m_sessionRunning = true; internalRet->m_sessionRunning = true;
internalRet->setDriveStatus(common::dataStructures::DriveStatus::Starting); internalRet->setDriveStatus(common::dataStructures::DriveStatus::Starting);
driveStatusSetTime += timer.secs(utils::Timer::resetCounter);
log::ScopedParamContainer params(lc); log::ScopedParamContainer params(lc);
uint32_t existingMounts = 0; uint32_t existingMounts = 0;
try { try {
existingMounts=existingMountsSummary.at(tpType(m->tapePool, m->type)); existingMounts=existingMountsSummary.at(tpType(m->tapePool, m->type));
} catch (...) {} } catch (...) {}
schedulerDbTime = getMountInfoTime + queueTrimingTime + mountCreationTime + driveStatusSetTime;
catalogueTime = getTapeInfoTime + getTapeForWriteTime;
params.add("tapepool", m->tapePool) params.add("tapepool", m->tapePool)
.add("vid", t.vid) .add("vid", t.vid)
.add("mountType", common::dataStructures::toString(m->type)) .add("mountType", common::dataStructures::toString(m->type))
...@@ -647,7 +671,17 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -647,7 +671,17 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
.add("filesQueued", m->filesQueued) .add("filesQueued", m->filesQueued)
.add("minFilesToWarrantMount", m_minFilesToWarrantAMount) .add("minFilesToWarrantMount", m_minFilesToWarrantAMount)
.add("oldestJobAge", time(NULL) - m->oldestJobStartTime) .add("oldestJobAge", time(NULL) - m->oldestJobStartTime)
.add("minArchiveRequestAge", m->minArchiveRequestAge); .add("minArchiveRequestAge", m->minArchiveRequestAge)
.add("getMountInfoTime", getMountInfoTime)
.add("queueTrimingTime", queueTrimingTime)
.add("getTapeInfoTime", getTapeInfoTime)
.add("candidateSortingTime", candidateSortingTime)
.add("getTapeForWriteTime", getTapeForWriteTime)
.add("decisionTime", decisionTime)
.add("mountCreationTime", mountCreationTime)
.add("driveStatusSetTime", driveStatusSetTime)
.add("schedulerDbTime", schedulerDbTime)
.add("catalogueTime", catalogueTime);
lc.log(log::DEBUG, "In Scheduler::getNextMount(): Selected next mount (archive)"); lc.log(log::DEBUG, "In Scheduler::getNextMount(): Selected next mount (archive)");
return std::unique_ptr<TapeMount> (internalRet.release()); return std::unique_ptr<TapeMount> (internalRet.release());
} catch (cta::exception::Exception & ex) { } catch (cta::exception::Exception & ex) {
...@@ -665,6 +699,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -665,6 +699,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
if (tapesInUse.count(m->vid)) continue; if (tapesInUse.count(m->vid)) continue;
try { try {
// create the mount, and populate its DB side. // create the mount, and populate its DB side.
decisionTime += timer.secs(utils::Timer::resetCounter);
std::unique_ptr<RetrieveMount> internalRet ( std::unique_ptr<RetrieveMount> internalRet (
new RetrieveMount(mountInfo->createRetrieveMount(m->vid, new RetrieveMount(mountInfo->createRetrieveMount(m->vid,
m->tapePool, m->tapePool,
...@@ -672,15 +707,19 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -672,15 +707,19 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
logicalLibraryName, logicalLibraryName,
utils::getShortHostname(), utils::getShortHostname(),
time(NULL)))); time(NULL))));
mountCreationTime += timer.secs(utils::Timer::resetCounter);
internalRet->m_sessionRunning = true; internalRet->m_sessionRunning = true;
internalRet->m_diskRunning = true; internalRet->m_diskRunning = true;
internalRet->m_tapeRunning = true; internalRet->m_tapeRunning = true;
internalRet->setDriveStatus(common::dataStructures::DriveStatus::Starting); internalRet->setDriveStatus(common::dataStructures::DriveStatus::Starting);
driveStatusSetTime += timer.secs(utils::Timer::resetCounter);
log::ScopedParamContainer params(lc); log::ScopedParamContainer params(lc);
uint32_t existingMounts = 0; uint32_t existingMounts = 0;
try { try {
existingMounts=existingMountsSummary.at(tpType(m->tapePool, m->type)); existingMounts=existingMountsSummary.at(tpType(m->tapePool, m->type));
} catch (...) {} } catch (...) {}
schedulerDbTime = getMountInfoTime + queueTrimingTime + mountCreationTime + driveStatusSetTime;
catalogueTime = getTapeInfoTime + getTapeForWriteTime;
params.add("tapepool", m->tapePool) params.add("tapepool", m->tapePool)
.add("vid", m->vid) .add("vid", m->vid)
.add("mountType", common::dataStructures::toString(m->type)) .add("mountType", common::dataStructures::toString(m->type))
...@@ -690,7 +729,17 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -690,7 +729,17 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
.add("filesQueued", m->filesQueued) .add("filesQueued", m->filesQueued)
.add("minFilesToWarrantMount", m_minFilesToWarrantAMount) .add("minFilesToWarrantMount", m_minFilesToWarrantAMount)
.add("oldestJobAge", time(NULL) - m->oldestJobStartTime) .add("oldestJobAge", time(NULL) - m->oldestJobStartTime)
.add("minArchiveRequestAge", m->minArchiveRequestAge); .add("minArchiveRequestAge", m->minArchiveRequestAge)
.add("getMountInfoTime", getMountInfoTime)
.add("queueTrimingTime", queueTrimingTime)
.add("getTapeInfoTime", getTapeInfoTime)
.add("candidateSortingTime", candidateSortingTime)
.add("getTapeForWriteTime", getTapeForWriteTime)
.add("decisionTime", decisionTime)
.add("mountCreationTime", mountCreationTime)
.add("driveStatusSetTime", driveStatusSetTime)
.add("schedulerDbTime", schedulerDbTime)
.add("catalogueTime", catalogueTime);
lc.log(log::DEBUG, "In Scheduler::getNextMount(): Selected next mount (retrieve)"); lc.log(log::DEBUG, "In Scheduler::getNextMount(): Selected next mount (retrieve)");
return std::unique_ptr<TapeMount> (internalRet.release()); return std::unique_ptr<TapeMount> (internalRet.release());
} catch (exception::Exception & ex) { } catch (exception::Exception & ex) {
...@@ -703,6 +752,19 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib ...@@ -703,6 +752,19 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
throw std::runtime_error("In Scheduler::getNextMount unexpected mount type"); throw std::runtime_error("In Scheduler::getNextMount unexpected mount type");
} }
} }
schedulerDbTime = getMountInfoTime + queueTrimingTime + mountCreationTime + driveStatusSetTime;
catalogueTime = getTapeInfoTime + getTapeForWriteTime;
log::ScopedParamContainer params(lc);
params.add("getMountInfoTime", getMountInfoTime)
.add("queueTrimingTime", queueTrimingTime)
.add("getTapeInfoTime", getTapeInfoTime)
.add("candidateSortingTime", candidateSortingTime)
.add("getTapeForWriteTime", getTapeForWriteTime)
.add("decisionTime", decisionTime)
.add("mountCreationTime", mountCreationTime)
.add("driveStatusSetTime", driveStatusSetTime)
.add("schedulerDbTime", schedulerDbTime)
.add("catalogueTime", catalogueTime);
lc.log(log::DEBUG, "In Scheduler::getNextMount(): No valid mount found."); lc.log(log::DEBUG, "In Scheduler::getNextMount(): No valid mount found.");
return std::unique_ptr<TapeMount>(); return std::unique_ptr<TapeMount>();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment