Page MenuHomePhabricator

D20200.id.diff
No OneTemporary

D20200.id.diff

diff --git a/resources/sql/autopatches/20190220.daemon_worker.completed.01.sql b/resources/sql/autopatches/20190220.daemon_worker.completed.01.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190220.daemon_worker.completed.01.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_worker.worker_archivetask
+ ADD archivedEpoch INT UNSIGNED NULL;
diff --git a/resources/sql/autopatches/20190220.daemon_worker.completed.02.sql b/resources/sql/autopatches/20190220.daemon_worker.completed.02.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190220.daemon_worker.completed.02.sql
@@ -0,0 +1,3 @@
+ALTER TABLE {$NAMESPACE}_worker.worker_activetask
+ ADD dateCreated int unsigned NOT NULL,
+ ADD dateModified int unsigned NOT NULL;
diff --git a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
--- a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
+++ b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
@@ -31,6 +31,7 @@
$completed_info[$class] = array(
'n' => 0,
'duration' => 0,
+ 'queueTime' => 0,
);
}
$completed_info[$class]['n']++;
@@ -41,16 +42,33 @@
// compute utilization.
$usage_total += $lease_overhead + ($duration / 1000000);
$usage_start = min($usage_start, $completed_task->getDateModified());
+
+ $date_archived = $completed_task->getArchivedEpoch();
+ $queue_seconds = $date_archived - $completed_task->getDateCreated();
+
+ // Don't measure queue time for tasks that completed in the same
+ // epoch-second they were created in.
+ if ($queue_seconds > 0) {
+ $sec_in_us = phutil_units('1 second in microseconds');
+ $queue_us = $queue_seconds * $sec_in_us;
+ $queue_exclusive_us = $queue_us - $duration;
+ $queue_exclusive_seconds = $queue_exclusive_us / $sec_in_us;
+ $rounded = floor($queue_exclusive_seconds);
+ $completed_info[$class]['queueTime'] += $rounded;
+ }
}
$completed_info = isort($completed_info, 'n');
$rows = array();
foreach ($completed_info as $class => $info) {
+ $duration_avg = new PhutilNumber((int)($info['duration'] / $info['n']));
+ $queue_avg = new PhutilNumber((int)($info['queueTime'] / $info['n']));
$rows[] = array(
$class,
number_format($info['n']),
- pht('%s us', new PhutilNumber((int)($info['duration'] / $info['n']))),
+ pht('%s us', $duration_avg),
+ pht('%s s', $queue_avg),
);
}
@@ -98,6 +116,7 @@
phutil_tag('em', array(), pht('Queue Utilization (Approximate)')),
sprintf('%.1f%%', 100 * $used_time),
null,
+ null,
);
}
@@ -108,13 +127,15 @@
array(
pht('Class'),
pht('Count'),
- pht('Avg'),
+ pht('Average Duration'),
+ pht('Average Queue Time'),
));
$completed_table->setColumnClasses(
array(
'wide',
'n',
'n',
+ 'n',
));
$completed_panel = id(new PHUIObjectBoxView())
diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
--- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
+++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
@@ -12,7 +12,6 @@
$config = array(
self::CONFIG_IDS => self::IDS_COUNTER,
- self::CONFIG_TIMESTAMPS => false,
self::CONFIG_KEY_SCHEMA => array(
'taskClass' => array(
'columns' => array('taskClass'),
@@ -118,7 +117,9 @@
->setPriority($this->getPriority())
->setObjectPHID($this->getObjectPHID())
->setResult($result)
- ->setDuration($duration);
+ ->setDuration($duration)
+ ->setDateCreated($this->getDateCreated())
+ ->setArchivedEpoch(PhabricatorTime::getNow());
// NOTE: This deletes the active task (this object)!
$archive->save();
diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
--- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
+++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
@@ -8,6 +8,7 @@
protected $duration;
protected $result;
+ protected $archivedEpoch;
protected function getConfiguration() {
$parent = parent::getConfiguration();
@@ -22,6 +23,7 @@
$config[self::CONFIG_COLUMN_SCHEMA] = array(
'result' => 'uint32',
'duration' => 'uint64',
+ 'archivedEpoch' => 'epoch?',
) + $config[self::CONFIG_COLUMN_SCHEMA];
$config[self::CONFIG_KEY_SCHEMA] = array(
@@ -85,6 +87,7 @@
->setDataID($this->getDataID())
->setPriority($this->getPriority())
->setObjectPHID($this->getObjectPHID())
+ ->setDateCreated($this->getDateCreated())
->insert();
$this->setDataID(null);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 15, 9:07 AM (2 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6739032
Default Alt Text
D20200.id.diff (5 KB)

Event Timeline