diff --git a/src/hydra-eval-jobs/Makefile.am b/src/hydra-eval-jobs/Makefile.am index c31849d9..7a4e9c91 100644 --- a/src/hydra-eval-jobs/Makefile.am +++ b/src/hydra-eval-jobs/Makefile.am @@ -2,5 +2,4 @@ bin_PROGRAMS = hydra-eval-jobs hydra_eval_jobs_SOURCES = hydra-eval-jobs.cc hydra_eval_jobs_LDADD = $(NIX_LIBS) - -AM_CXXFLAGS = $(NIX_CFLAGS) +hydra_eval_jobs_CXXFLAGS = $(NIX_CFLAGS) -I ../libhydra diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 1e17e99d..d6f82276 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -13,6 +13,8 @@ #include "globals.hh" #include "common-eval-args.hh" +#include "hydra-config.hh" + using namespace nix; @@ -157,6 +159,13 @@ int main(int argc, char * * argv) unsetenv("NIX_PATH"); return handleExceptions(argv[0], [&]() { + + auto config = std::make_unique<::Config>(); + + auto initialHeapSize = config->getStrOption("evaluator_initial_heap_size", ""); + if (initialHeapSize != "") + setenv("GC_INITIAL_HEAP_SIZE", initialHeapSize.c_str(), 1); + initNix(); initGC(); diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index eec51770..70329a9e 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -10,10 +10,11 @@ #include "store-api.hh" #include "remote-store.hh" -#include "shared.hh" #include "globals.hh" +#include "hydra-config.hh" #include "json.hh" #include "s3-binary-cache-store.hh" +#include "shared.hh" using namespace nix; @@ -27,52 +28,6 @@ template<> void toJSON(std::ostream & str, const double & n) { str << n; } -struct Config -{ - std::map options; - - Config() - { - /* Read hydra.conf. */ - auto hydraConfigFile = getEnv("HYDRA_CONFIG"); - if (pathExists(hydraConfigFile)) { - - for (auto line : tokenizeString(readFile(hydraConfigFile), "\n")) { - line = trim(string(line, 0, line.find('#'))); - - auto eq = line.find('='); - if (eq == std::string::npos) continue; - - auto key = trim(std::string(line, 0, eq)); - auto value = trim(std::string(line, eq + 1)); - - if (key == "") continue; - - options[key] = value; - } - } - } - - std::string getStrOption(const std::string & key, const std::string & def = "") - { - auto i = options.find(key); - return i == options.end() ? def : i->second; - } - - uint64_t getIntOption(const std::string & key, uint64_t def = 0) - { - auto i = options.find(key); - return i == options.end() ? def : std::stoll(i->second); - } - - bool getBoolOption(const std::string & key, bool def = false) - { - auto i = options.find(key); - return i == options.end() ? def : (i->second == "true" || i->second == "1"); - } -}; - - static uint64_t getMemSize() { auto pages = sysconf(_SC_PHYS_PAGES); diff --git a/src/libhydra/hydra-config.hh b/src/libhydra/hydra-config.hh new file mode 100644 index 00000000..a4050666 --- /dev/null +++ b/src/libhydra/hydra-config.hh @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include "util.hh" + +struct Config +{ + std::map options; + + Config() + { + using namespace nix; + + /* Read hydra.conf. */ + auto hydraConfigFile = getEnv("HYDRA_CONFIG"); + if (pathExists(hydraConfigFile)) { + + for (auto line : tokenizeString(readFile(hydraConfigFile), "\n")) { + line = trim(string(line, 0, line.find('#'))); + + auto eq = line.find('='); + if (eq == std::string::npos) continue; + + auto key = trim(std::string(line, 0, eq)); + auto value = trim(std::string(line, eq + 1)); + + if (key == "") continue; + + options[key] = value; + } + } + } + + std::string getStrOption(const std::string & key, const std::string & def = "") + { + auto i = options.find(key); + return i == options.end() ? def : i->second; + } + + uint64_t getIntOption(const std::string & key, uint64_t def = 0) + { + auto i = options.find(key); + return i == options.end() ? def : std::stoll(i->second); + } + + bool getBoolOption(const std::string & key, bool def = false) + { + auto i = options.find(key); + return i == options.end() ? def : (i->second == "true" || i->second == "1"); + } +};