hydra-eval-jobs: Ugly hackery to reduce memory usage
[?]
Jun 5, 2018, 10:18 AM
5MP35ORVVILU3GXYITYXD754QFZCOZ3X45QO54K2GW5UKNHX66SACDependencies
- [2]
4GTOWRFWhydra-eval-jobs: Fix build - [3]
HP5WJLQUhydra-eval-{jobs,jobset}: Pass file name as <...> - [4]
ZVSHXE3KAllow setting GC_INITIAL_HEAP_SIZE for hydra-eval-jobs - [5]
FGLKIVYSFix build against Nix master - [6]
AEKIREIH* Updated hydra_eval_jobs for the new evaluator. - [7]
YNGIYQRFhydra-eval-jobs: Don't keep track of used inputs - [8]
4N5APGRG* Start of a helper tool to evaluate job expressions efficiently. - [9]
WMWBCZPR - [10]
VTMBJVIShydra-eval-jobs: Disable the build hook. - [11]
52JSLNC6* Build fix. - [12]
MIC2O6ZFUse evalFile() instead of parseExprFromFile() - [13]
M5BEPXTETweak debug output - [14]
I2HYJBMLDebug tweak - [15]
FUB37KFUUse Nix's restricted evaluation mode - [16]
STZE4KKRFix build against Nix master - [17]
DKJFD6JNProcess Nix API changes - [18]
FGUL3HAZhydra-eval-jobs: Don't go into an infinite recursion - [19]
IMQRX4MPhydra-eval-jobs: Use JSON instead of XML - [20]
7YCFGMZB* Report evaluation errors per job, and don't bail out if a job fails - [21]
HNGPGVBTFix build - [22]
77VF5TC6* For ease of use during debugging, don't require --gc-roots-dir. - [23]
POPU2ATH* hydra_scheduler: use eval-jobs. - [24]
4LWGZL33 - [25]
7GKAIP3VFix build and handling of string inputs starting with a dash - [26]
VTNP5KDO* Don't catch all errors. Some errors mess up the connection with the - [27]
3PNG7NIBRemove trailing whitespace - [*]
KD5237CU* eval-jobs now efficiently evaluates all Hydra jobs from a - [*]
L4LBF7UFHandle derivations without a system attribute - [*]
EBG4P4SYDoh - clear $NIX_PATH properly
Change contents
- edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 18
#include <sys/types.h>#include <sys/wait.h> - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 55
static std::string lastAttrPath;static bool comma = false;static size_t maxHeapSize;struct BailOut { }; - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 65
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;}} - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 90
if (lastAttrPath != "" && lte(attrPath, lastAttrPath)) return; - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 110
if (comma) { std::cout << ","; comma = false; } - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 157
}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(); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 171
for (auto & i : *v.attrs)findJobs(state, top, autoArgs, *i.value,(attrPath.empty() ? "" : attrPath + ".") + (string) i.name);for (auto & i : v.attrs->lexicographicOrder()) {std::string name(i->name);/* Skip jobs with dots in the name. */if (name.find('.') != std::string::npos) {printError("skipping job with illegal name '%s'", name);continue;}findJobs(state, top, autoArgs, *i->value,(attrPath.empty() ? "" : attrPath + ".") + name);} - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 202
{if (comma) { std::cout << ","; comma = false; } - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 205
} - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 211[6.570][31.0]
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")); - edit in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 231
maxHeapSize = config->getIntOption("evaluator_max_heap_size", 1UL << 30); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 257
/* FIXME: The build hook in conjunction with import-from-derivation is causing "unexpected EOF" during eval */settings.builders = "";JSONObject json(std::cout, true);std::cout.flush(); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 260
/* Prevent access to paths outside of the Nix search path andto the environment. */evalSettings.restrictEval = true;do {Pipe pipe;pipe.create(); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 265
if (releaseExpr == "") throw UsageError("no expression specified");ProcessOptions options;options.allowVfork = false; - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 268
if (gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified");auto pid = startProcess([&]() {pipe.readSide = -1; - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 271
EvalState state(myArgs.searchPath, openStore());if (lastAttrPath != "") debug("resuming from '%s'", lastAttrPath); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 273
Bindings & autoArgs = *myArgs.getAutoArgs(state);/* FIXME: The build hook in conjunction with import-from-derivation is causing "unexpected EOF" during eval */settings.builders = ""; - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 276
Value v;state.evalFile(lookupFileArg(state, releaseExpr), v);/* Prevent access to paths outside of the Nix search path andto the environment. */evalSettings.restrictEval = true; - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 280
JSONObject json(std::cout, true);findJobs(state, json, autoArgs, v, "");if (releaseExpr == "") throw UsageError("no expression specified"); - replacement in src/hydra-eval-jobs/hydra-eval-jobs.cc at line 282
state.printStats();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);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);lastAttrPath = drainFD(pipe.readSide.get());} while (lastAttrPath != "");