Remove the hydra-eval-jobs restart hack

It's not very effective.
This commit is contained in:
Eelco Dolstra 2019-05-10 21:57:19 +02:00
parent 80fe42e77e
commit 8f3114960c
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -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,
Bindings & autoArgs, Value & vIn, const string & attrPath)
{
if (lastAttrPath != "" && lte(attrPath, lastAttrPath)) return;
debug(format("at path `%1%'") % attrPath);
checkInterrupt();
@ -109,8 +77,6 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
if (drv->querySystem() == "unknown")
throw EvalError("derivation must have a system attribute");
if (comma) { std::cout << ","; comma = false; }
{
auto res = top.object(attrPath);
res.attr("nixName", drv->queryName());
@ -156,15 +122,6 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
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 {
@ -200,7 +157,6 @@ static void findJobs(EvalState & state, JSONObject & top,
try {
findJobsWrapped(state, top, autoArgs, v, attrPath);
} catch (EvalError & e) {
if (comma) { std::cout << ","; comma = false; }
auto res = top.object(attrPath);
res.attr("error", filterANSIEscapes(e.msg(), true));
}
@ -209,14 +165,6 @@ static void findJobs(EvalState & state, JSONObject & top,
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
$NIX_PATH. */
unsetenv("NIX_PATH");
@ -229,23 +177,9 @@ int main(int argc, char * * argv)
if (initialHeapSize != "")
setenv("GC_INITIAL_HEAP_SIZE", initialHeapSize.c_str(), 1);
maxHeapSize = config->getIntOption("evaluator_max_heap_size", 1UL << 30);
initNix();
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;
struct MyArgs : LegacyArgs, MixEvalArgs
@ -270,24 +204,6 @@ int main(int argc, char * * argv)
JSONObject json(std::cout, true);
std::cout.flush();
do {
Pipe pipe;
pipe.create();
ProcessOptions options;
options.allowVfork = false;
GC_atfork_prepare();
auto pid = startProcess([&]() {
pipe.readSide = -1;
GC_atfork_child();
GC_start_mark_threads();
if (lastAttrPath != "") debug("resuming from '%s'", lastAttrPath);
/* FIXME: The build hook in conjunction with import-from-derivation is causing "unexpected EOF" during eval */
settings.builders = "";
@ -306,35 +222,7 @@ int main(int argc, char * * argv)
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 != "");
});
}