mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
5b1a00eab1
Summary: - Add flags to exit after an idle time or client count. - Add flags to control daemonization. - Add flags to control output. - Add flags to skip the "hello" frame of the protocol. - Make the client launch a server if one does not exist. The one-time overhead to launch a server and run a command through it looks to be ~130% of the overhead to run the command directly with "hg", so even if we never run a second command we're not paying too much. The incremental overhead to run subsequent command appears to be less than 3% of the overhead to run the command directly with "hg" (and maybe less than 1%, I'm not sure how long the computation part of a command like 'hg log' "actually" takes). The overhead to launch a PHP client, connect to an existing server, run a command, and then print it and exit is roughly 50% of the overhead to run the command directly with "hg". So theoretically a user can achieve an amortized 2x performance increase for all 'hg' commands by aliasing 'hg' to the PHP client in their shell. Test Plan: - Ran servers with idle and client count limits, let them idle and/or hit their connection limits, saw them exit. - Ran foreground and background servers. - Ran a daemon server with redirected stdout/stderr. Verified logs appeared. - Ran with --quiet. - Ran clients and servers with and without --skip-hello, things work if they agree and break if they disagree. The throughput gain on this is fairly small (maybe 5%?) but it seems simple enough to keep for the moment. - Ran serverless clients and verified that servers launched the first time, were available subsequently, and relaunched after 15 seconds idle. Reviewers: csilvers, vrana, btrahan Reviewed By: csilvers CC: aran Differential Revision: https://secure.phabricator.com/D2680
56 lines
1.6 KiB
PHP
Executable file
56 lines
1.6 KiB
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/*
|
|
* Copyright 2012 Facebook, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
|
|
|
|
$args = new PhutilArgumentParser($argv);
|
|
$args->parseStandardArguments();
|
|
$args->parse(
|
|
array(
|
|
array(
|
|
'name' => 'skip-hello',
|
|
'help' => 'Do not expect "capability" message when connecting. '.
|
|
'The server must be configured not to send the message. '.
|
|
'This deviates from the Mercurial protocol, but slightly '.
|
|
'improves performance.',
|
|
),
|
|
array(
|
|
'name' => 'repository',
|
|
'wildcard' => true,
|
|
),
|
|
));
|
|
|
|
$repo = $args->getArg('repository');
|
|
if (count($repo) !== 1) {
|
|
throw new Exception("Specify exactly one working copy!");
|
|
}
|
|
$repo = head($repo);
|
|
|
|
$client = new ArcanistHgProxyClient($repo);
|
|
$client->setSkipHello($args->getArg('skip-hello'));
|
|
|
|
$t_start = microtime(true);
|
|
|
|
$result = $client->executeCommand(
|
|
array('log', '--template', '{node}', '--rev', 2));
|
|
|
|
$t_end = microtime(true);
|
|
var_dump($result);
|
|
|
|
echo "\nExecuted in ".((int)(1000000 * ($t_end - $t_start)))."us.\n";
|