From 936f9d45baf474358346666ed9ad7f56960bb455 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 6 Sep 2013 16:36:56 +0200 Subject: Don't apply the CPU affinity hack to nix-shell (and other Perl programs) As discovered by Todd Veldhuizen, the shell started by nix-shell has its affinity set to a single CPU. This is because nix-shell connects to the Nix daemon, which causes the affinity hack to be applied. So we turn this off for Perl programs. --- src/libstore/globals.cc | 1 + src/libstore/globals.hh | 3 +++ src/libstore/remote-store.cc | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libstore') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index aeb52e1a8696..7e0157cd365a 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -54,6 +54,7 @@ Settings::Settings() gcKeepDerivations = true; autoOptimiseStore = false; envKeepDerivations = false; + lockCPU = getEnv("NIX_AFFINITY_HACK", "1") == "1"; } diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 50b61725c742..cbc6d4e9848e 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -183,6 +183,9 @@ struct Settings { (to prevent them from being GCed). */ bool envKeepDerivations; + /* Whether to lock the Nix client and worker to the same CPU. */ + bool lockCPU; + private: SettingsMap settings, overrides; diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 3764b4813a4e..3017254baf3b 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -73,7 +73,7 @@ void RemoteStore::openConnection(bool reserveSpace) writeInt(PROTOCOL_VERSION, to); if (GET_PROTOCOL_MINOR(daemonVersion) >= 14) { - int cpu = lockToCurrentCPU(); + int cpu = settings.lockCPU ? lockToCurrentCPU() : -1; if (cpu != -1) { writeInt(1, to); writeInt(cpu, to); -- cgit 1.4.1