Skip to content

Commit

Permalink
Realtime report needs update for Trick job thread id
Browse files Browse the repository at this point in the history
I was taking a job name like:
    JOB_thread_process_event_3.ep.process_event_C3.266.03
and parsing out the thread ID from the name.  I assumed Trick's
naming convention added the CX for the thread ID.  I think Trick
used to adhere to that, but maybe I made a bad assumption.
This issue came up because there were jobs with the _CX.num.num
suffix where the X was NOT the thread ID.

Instead of getting the threadID from the job name,
use the filename the job comes from. For example,
if the job comes from:
    log_trick_frame_userjobs_C5.trk
it belongs to thread 5.

Another example is the following job name:
    JOB_thread_process_event_3.ep.process_event_C3.266.03(automatic_1.000)
which came from file:
    log_frame_trickjobs.trk
Even though the job has "C3.266.03", it's not in child thread 3,
it's in thread 0, since log_frame_trickjobs.trk logs jobs in
thread 0.
  • Loading branch information
keithvetter committed Aug 30, 2024
1 parent 373aa4e commit f5d6850
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
50 changes: 20 additions & 30 deletions libkoviz/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ double Job::stddev_runtime()
return _stddev_runtime;
}

void Job::_parseJobId(const QString &jobId)
void Job::_parseJobId(const QString &jobId, const QString &fileName)
{
QString name(jobId);

Expand All @@ -178,14 +178,14 @@ void Job::_parseJobId(const QString &jobId)
// e.g. 1828.00 from example name
int idx4 = name.lastIndexOf(QChar('.'),idx1);
int idx5 = name.lastIndexOf(QChar('.'),idx4-1);
_job_name = name.mid(0,idx5); // _job_name may be reset below
_job_num = name.mid(idx5+1,idx1-idx5-1);

_isFrameTimerJob = false;
if ( (
jobId.startsWith("trick_frame_userjobs_C") ||
if ((jobId.startsWith("trick_frame_userjobs_C") ||
jobId.startsWith("frame_userjobs_C") ||
jobId.startsWith("snap_userjobs_C")) &&
jobId.endsWith("frame_time") ) {
jobId.endsWith("frame_time")) {
_isFrameTimerJob = true;
}

Expand Down Expand Up @@ -220,23 +220,22 @@ void Job::_parseJobId(const QString &jobId)
} else {

_thread_id = 0 ;
QString stid;
int idx6;
for ( idx6 = idx5-1 ; idx6 > 0 ; idx6-- ) {
if ( isdigit(name.at(idx6).toLatin1()) ) {
stid.prepend(name.at(idx6));
} else {
if ( name.at(idx6) == 'C' && name.at(idx6-1) == '_' ) {
_thread_id = stid.toInt();
idx6--;
} else {
idx6++;
}
break;
}
QFileInfo fi(fileName);
QString fname = fi.fileName();
QRegularExpression rgx("log_trick_frame_userjobs_C(\\d+).trk");
QRegularExpressionMatch match = rgx.match(fname);
if (match.hasMatch()) {
QString number = match.captured(1);
_thread_id = number.toInt();
} else if ((fname == "log_frame.trk") ||
(fname == "log_frame_trickjobs.trk") ||
(fname == "log_frame_userjobs_main.trk")) {
_thread_id = 0;
} else {
fprintf(stderr, "koviz [error]: Job::_parseJobId(): cannot find "
"file to determine thread id!\n");
exit(-1);
}

_job_name = name.mid(0,idx6);
}
}

Expand All @@ -251,7 +250,6 @@ double Job::freq()
// Parse long logname and set job members accordingly
// An example logname:
// JOB_schedbus.SimBus##read_ALDS15_ObcsRouter_C1.1828.00(read_simbus_0.100)

Job::Job(CurveModel* curve) :
_curve(curve),_npoints(0),_isFrameTimerJob(false),
_is_stats(false)
Expand All @@ -263,15 +261,7 @@ Job::Job(CurveModel* curve) :
_npoints = curve->rowCount();
_log_name = curve->y()->name();

_parseJobId(_log_name);
}

Job::Job(const QString &jobId) :
_curve(0),_npoints(0),_isFrameTimerJob(false),
_log_name(jobId),
_is_stats(false)
{
_parseJobId(_log_name);
_parseJobId(_log_name,curve->fileName());
}

QString Job::job_id() const
Expand Down
5 changes: 3 additions & 2 deletions libkoviz/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QString>
#include <QTextStream>
#include <QFileInfo>
#include <QRegularExpression>
#include <stdlib.h>
#include <stdexcept>

Expand All @@ -19,7 +21,6 @@ class Job
// job_id is logged job name
// e.g. JOB_bus.SimBus##read_ObcsRouter_C1.1828.00(read_simbus_0.100)
Job(CurveModel* curve);
Job(const QString& job_id);

bool isFrameTimerJob() { return _isFrameTimerJob; }

Expand All @@ -42,7 +43,7 @@ class Job
private:
Job() {}

void _parseJobId(const QString& job_id);
void _parseJobId(const QString& job_id, const QString& fileName);

CurveModel* _curve;
int _npoints;
Expand Down

0 comments on commit f5d6850

Please sign in to comment.