1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Reduce parse latency for changes pushed to hosted repositories

Summary:
Currently, we can sit in a sleep() for up to 15 seconds (or longer, in some cases), even if there's a parse request.

Try polling the DB every second to see if we should wake up instead. This might or might not produce significant improvements, but seems OK to try and see.

Also a small fix for logging branch names with `%` in them, etc.

Test Plan: Ran `phd debug pulllocal` and pushed commits, saw them parse within a second.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, dctrwatson

Differential Revision: https://secure.phabricator.com/D7998
This commit is contained in:
epriestley 2014-01-17 16:09:51 -08:00
parent 8520d9e070
commit a9c16fbe4e
2 changed files with 13 additions and 5 deletions

View file

@ -87,9 +87,7 @@ final class PhabricatorRepositoryPullLocalDaemon
// If any repositories have the NEEDS_UPDATE flag set, pull them
// as soon as possible.
$type_need_update = PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE;
$need_update_messages = id(new PhabricatorRepositoryStatusMessage())
->loadAllWhere('statusType = %s', $type_need_update);
$need_update_messages = $this->loadRepositoryUpdateMessages();
foreach ($need_update_messages as $message) {
$retry_after[$message->getRepositoryID()] = time();
}
@ -184,10 +182,20 @@ final class PhabricatorRepositoryPullLocalDaemon
$sleep_until = time() + $min_sleep;
}
$this->sleep($sleep_until - time());
while (($sleep_until - time()) > 0) {
$this->sleep(1);
if ($this->loadRepositoryUpdateMessages()) {
break;
}
}
}
}
private function loadRepositoryUpdateMessages() {
$type_need_update = PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE;
return id(new PhabricatorRepositoryStatusMessage())
->loadAllWhere('statusType = %s', $type_need_update);
}
/**
* @task pull

View file

@ -54,7 +54,7 @@ abstract class PhabricatorRepositoryEngine {
if ($this->getVerbose()) {
$console = PhutilConsole::getConsole();
$argv = func_get_args();
$argv[0] = $argv[0]."\n";
array_unshift($argv, "%s\n");
call_user_func_array(array($console, 'writeOut'), $argv);
}
return $this;