From d6a56081401a7ffde9e41c685225630295cf9c4e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 9 Apr 2018 23:59:49 +0200 Subject: [PATCH] Show which path in the large path warning Fixes https://github.com/NixOS/nix/issues/1184. --- src/libstore/local-store.cc | 1 + src/libutil/serialise.cc | 20 -------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e6ba0e6e4e22..ba3637991d0d 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1140,6 +1140,7 @@ Path LocalStore::addToStore(const string & name, const Path & _srcPath, if (inMemory) { if (nar.size() + len > settings.narBufferSize) { + printError("warning: adding very large path '%s' to the Nix store", srcPath); inMemory = false; sink << 1; sink((const unsigned char *) nar.data(), nar.size()); diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc index 0e75eeec2bfe..df6f04901372 100644 --- a/src/libutil/serialise.cc +++ b/src/libutil/serialise.cc @@ -48,24 +48,9 @@ FdSink::~FdSink() } -size_t threshold = 256 * 1024 * 1024; - -static void warnLargeDump() -{ - printError("warning: dumping very large path (> 256 MiB); this may run out of memory"); -} - - void FdSink::write(const unsigned char * data, size_t len) { written += len; - static bool warned = false; - if (warn && !warned) { - if (written > threshold) { - warnLargeDump(); - warned = true; - } - } try { writeFull(fd, data, len); } catch (SysError & e) { @@ -311,11 +296,6 @@ template PathSet readStrings(Source & source); void StringSink::operator () (const unsigned char * data, size_t len) { - static bool warned = false; - if (!warned && s->size() > threshold) { - warnLargeDump(); - warned = true; - } s->append((const char *) data, len); }