forked from lix-project/hydra
Remove the hydra-eval-jobs restart hack
It's not very effective.
This commit is contained in:
parent
80fe42e77e
commit
8f3114960c
|
@ -55,41 +55,9 @@ static string queryMetaStrings(EvalState & state, DrvInfo & drv, const string &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::string lastAttrPath;
|
|
||||||
static bool comma = false;
|
|
||||||
static size_t maxHeapSize;
|
|
||||||
|
|
||||||
|
|
||||||
struct BailOut { };
|
|
||||||
|
|
||||||
|
|
||||||
bool lte(const std::string & s1, const std::string & s2)
|
|
||||||
{
|
|
||||||
size_t p1 = 0, p2 = 0;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (p1 == s1.size()) return p2 == s2.size();
|
|
||||||
if (p2 == s2.size()) return true;
|
|
||||||
|
|
||||||
auto d1 = s1.find('.', p1);
|
|
||||||
auto d2 = s2.find('.', p2);
|
|
||||||
|
|
||||||
auto c = s1.compare(p1, d1 - p1, s2, p2, d2 - p2);
|
|
||||||
|
|
||||||
if (c < 0) return true;
|
|
||||||
if (c > 0) return false;
|
|
||||||
|
|
||||||
p1 = d1 == std::string::npos ? s1.size() : d1 + 1;
|
|
||||||
p2 = d2 == std::string::npos ? s2.size() : d2 + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void findJobsWrapped(EvalState & state, JSONObject & top,
|
static void findJobsWrapped(EvalState & state, JSONObject & top,
|
||||||
Bindings & autoArgs, Value & vIn, const string & attrPath)
|
Bindings & autoArgs, Value & vIn, const string & attrPath)
|
||||||
{
|
{
|
||||||
if (lastAttrPath != "" && lte(attrPath, lastAttrPath)) return;
|
|
||||||
|
|
||||||
debug(format("at path `%1%'") % attrPath);
|
debug(format("at path `%1%'") % attrPath);
|
||||||
|
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
@ -109,8 +77,6 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
|
||||||
if (drv->querySystem() == "unknown")
|
if (drv->querySystem() == "unknown")
|
||||||
throw EvalError("derivation must have a ‘system’ attribute");
|
throw EvalError("derivation must have a ‘system’ attribute");
|
||||||
|
|
||||||
if (comma) { std::cout << ","; comma = false; }
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto res = top.object(attrPath);
|
auto res = top.object(attrPath);
|
||||||
res.attr("nixName", drv->queryName());
|
res.attr("nixName", drv->queryName());
|
||||||
|
@ -156,15 +122,6 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
|
||||||
res2.attr(j.first, j.second);
|
res2.attr(j.first, j.second);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GC_prof_stats_s gc;
|
|
||||||
GC_get_prof_stats(&gc, sizeof(gc));
|
|
||||||
|
|
||||||
if (gc.heapsize_full > maxHeapSize) {
|
|
||||||
printInfo("restarting hydra-eval-jobs after job '%s' because heap size is at %d bytes", attrPath, gc.heapsize_full);
|
|
||||||
lastAttrPath = attrPath;
|
|
||||||
throw BailOut();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -200,7 +157,6 @@ static void findJobs(EvalState & state, JSONObject & top,
|
||||||
try {
|
try {
|
||||||
findJobsWrapped(state, top, autoArgs, v, attrPath);
|
findJobsWrapped(state, top, autoArgs, v, attrPath);
|
||||||
} catch (EvalError & e) {
|
} catch (EvalError & e) {
|
||||||
if (comma) { std::cout << ","; comma = false; }
|
|
||||||
auto res = top.object(attrPath);
|
auto res = top.object(attrPath);
|
||||||
res.attr("error", filterANSIEscapes(e.msg(), true));
|
res.attr("error", filterANSIEscapes(e.msg(), true));
|
||||||
}
|
}
|
||||||
|
@ -209,14 +165,6 @@ static void findJobs(EvalState & state, JSONObject & top,
|
||||||
|
|
||||||
int main(int argc, char * * argv)
|
int main(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
assert(lte("abc", "def"));
|
|
||||||
assert(lte("abc", "def.foo"));
|
|
||||||
assert(!lte("def", "abc"));
|
|
||||||
assert(lte("nixpkgs.hello", "nixpkgs"));
|
|
||||||
assert(lte("nixpkgs.hello", "nixpkgs.hellooo"));
|
|
||||||
assert(lte("gitAndTools.git-annex.x86_64-darwin", "gitAndTools.git-annex.x86_64-linux"));
|
|
||||||
assert(lte("gitAndTools.git-annex.x86_64-linux", "gitAndTools.git-annex-remote-b2.aarch64-linux"));
|
|
||||||
|
|
||||||
/* Prevent undeclared dependencies in the evaluation via
|
/* Prevent undeclared dependencies in the evaluation via
|
||||||
$NIX_PATH. */
|
$NIX_PATH. */
|
||||||
unsetenv("NIX_PATH");
|
unsetenv("NIX_PATH");
|
||||||
|
@ -229,23 +177,9 @@ int main(int argc, char * * argv)
|
||||||
if (initialHeapSize != "")
|
if (initialHeapSize != "")
|
||||||
setenv("GC_INITIAL_HEAP_SIZE", initialHeapSize.c_str(), 1);
|
setenv("GC_INITIAL_HEAP_SIZE", initialHeapSize.c_str(), 1);
|
||||||
|
|
||||||
maxHeapSize = config->getIntOption("evaluator_max_heap_size", 1UL << 30);
|
|
||||||
|
|
||||||
initNix();
|
initNix();
|
||||||
initGC();
|
initGC();
|
||||||
|
|
||||||
/* Read the current heap size, which is the initial heap size. */
|
|
||||||
GC_prof_stats_s gc;
|
|
||||||
GC_get_prof_stats(&gc, sizeof(gc));
|
|
||||||
auto initialHeapSizeInt = gc.heapsize_full;
|
|
||||||
|
|
||||||
/* Then make sure the maximum heap size will be bigger than the initial heap size. */
|
|
||||||
if (initialHeapSizeInt > maxHeapSize) {
|
|
||||||
printInfo("warning: evaluator_initial_heap_size (%d) bigger than evaluator_max_heap_size (%d).", initialHeapSizeInt, maxHeapSize);
|
|
||||||
maxHeapSize = initialHeapSizeInt * 1.1;
|
|
||||||
printInfo(" evaluator_max_heap_size now set to %d.", maxHeapSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
Path releaseExpr;
|
Path releaseExpr;
|
||||||
|
|
||||||
struct MyArgs : LegacyArgs, MixEvalArgs
|
struct MyArgs : LegacyArgs, MixEvalArgs
|
||||||
|
@ -270,71 +204,25 @@ int main(int argc, char * * argv)
|
||||||
JSONObject json(std::cout, true);
|
JSONObject json(std::cout, true);
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
|
|
||||||
do {
|
/* FIXME: The build hook in conjunction with import-from-derivation is causing "unexpected EOF" during eval */
|
||||||
|
settings.builders = "";
|
||||||
|
|
||||||
Pipe pipe;
|
/* Prevent access to paths outside of the Nix search path and
|
||||||
pipe.create();
|
to the environment. */
|
||||||
|
evalSettings.restrictEval = true;
|
||||||
|
|
||||||
ProcessOptions options;
|
if (releaseExpr == "") throw UsageError("no expression specified");
|
||||||
options.allowVfork = false;
|
|
||||||
|
|
||||||
GC_atfork_prepare();
|
if (gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified");
|
||||||
|
|
||||||
auto pid = startProcess([&]() {
|
EvalState state(myArgs.searchPath, openStore());
|
||||||
pipe.readSide = -1;
|
|
||||||
|
|
||||||
GC_atfork_child();
|
Bindings & autoArgs = *myArgs.getAutoArgs(state);
|
||||||
GC_start_mark_threads();
|
|
||||||
|
|
||||||
if (lastAttrPath != "") debug("resuming from '%s'", lastAttrPath);
|
Value v;
|
||||||
|
state.evalFile(lookupFileArg(state, releaseExpr), v);
|
||||||
|
|
||||||
/* FIXME: The build hook in conjunction with import-from-derivation is causing "unexpected EOF" during eval */
|
findJobs(state, json, autoArgs, v, "");
|
||||||
settings.builders = "";
|
|
||||||
|
|
||||||
/* Prevent access to paths outside of the Nix search path and
|
|
||||||
to the environment. */
|
|
||||||
evalSettings.restrictEval = true;
|
|
||||||
|
|
||||||
if (releaseExpr == "") throw UsageError("no expression specified");
|
|
||||||
|
|
||||||
if (gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified");
|
|
||||||
|
|
||||||
EvalState state(myArgs.searchPath, openStore());
|
|
||||||
|
|
||||||
Bindings & autoArgs = *myArgs.getAutoArgs(state);
|
|
||||||
|
|
||||||
Value v;
|
|
||||||
state.evalFile(lookupFileArg(state, releaseExpr), v);
|
|
||||||
|
|
||||||
comma = lastAttrPath != "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
findJobs(state, json, autoArgs, v, "");
|
|
||||||
lastAttrPath = "";
|
|
||||||
} catch (BailOut &) { }
|
|
||||||
|
|
||||||
writeFull(pipe.writeSide.get(), lastAttrPath);
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
GC_atfork_parent();
|
|
||||||
|
|
||||||
pipe.writeSide = -1;
|
|
||||||
|
|
||||||
int status;
|
|
||||||
while (true) {
|
|
||||||
checkInterrupt();
|
|
||||||
if (waitpid(pid, &status, 0) == pid) break;
|
|
||||||
if (errno != EINTR) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != 0)
|
|
||||||
throw Exit(WIFEXITED(status) ? WEXITSTATUS(status) : 99);
|
|
||||||
|
|
||||||
maxHeapSize += 64 * 1024 * 1024;
|
|
||||||
|
|
||||||
lastAttrPath = drainFD(pipe.readSide.get());
|
|
||||||
} while (lastAttrPath != "");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue