Reduce repo contention issues

If there were multiple processes (or threads) trying to write to
the repo, we were spending a lot of time in raw_spin_lock, resulting
in almost no forward progress. The new test case runs in about 8
seconds on my dev server, with a debug build, but didnt complete in
20 minutes when using the current release build of hhvm.

I also removed the 20 thread limit on the test runner, which
drops the time for SlowJit from about 1:45 to 1:30, and should
no longer cause repo-contention issues.
Esse commit está contido em:
Mark Williams
2013-05-01 11:26:17 -07:00
commit de Sara Golemon
commit 30075b74c9
4 arquivos alterados com 41 adições e 5 exclusões
+2 -2
Ver Arquivo
@@ -14,10 +14,10 @@
+----------------------------------------------------------------------+
*/
#include "runtime/vm/repo.h"
#include "util/logger.h"
#include "util/trace.h"
#include "util/repo_schema.h"
#include "runtime/vm/repo.h"
namespace HPHP {
namespace VM {
@@ -425,7 +425,7 @@ static int busyHandler(void* opaque, int nCalls) {
Repo* repo UNUSED = static_cast<Repo*>(opaque);
// yield to allow other threads access to the machine
// spin-wait can starve other threads.
sched_yield();
usleep(1000 * nCalls);
return 1; // Tell SQLite to retry.
}
+34
Ver Arquivo
@@ -0,0 +1,34 @@
<?php
function foobar($i) {
usleep(500*1000);
}
function main($num) {
$cmd = file_get_contents("/proc/self/cmdline");
$cmd = str_replace("\000", " ", $cmd);
$start = microtime(true);
echo "Starting $num procs\n";
for ($i = 0; $i < $num; $i++) {
$handles[] = proc_open($cmd." $i", array(), $pipes);
}
while ($handles) {
foreach ($handles as $i => $handle) {
$status = proc_get_status($handle);
if (!$status['running']) {
proc_close($handle);
unset($handles[$i]);
}
}
}
echo "Done $num procs\n";
return microtime(true) - $start;
}
if (count($argv) > 1) {
foobar($argv[1]);
} else {
$x10 = main(10);
$x200 = main(200);
echo $x10 * 20 < $x200 ? "Failed" : "Passed", "\n";
}
@@ -0,0 +1,5 @@
Starting 10 procs
Done 10 procs
Starting 200 procs
Done 200 procs
Passed
-3
Ver Arquivo
@@ -32,9 +32,6 @@ $opt_server = 0;
$opt_port = 8080;
$opt_home = ".";
$opt_threads = `cat /proc/cpuinfo | grep '^processor' | wc -l`;
if ($opt_threads > 20) {
$opt_threads = 20;
}
$opt_reduce = "";
$opt_coverage = "";
$opt_hhvm = "hhvm";