Skip to content

Commit

Permalink
Remove warnLargeDump()
Browse files Browse the repository at this point in the history
This message was unhelpful (NixOS#1184) and probably misleading since
memory is O(1) in most cases now.
  • Loading branch information
edolstra committed Aug 12, 2022
1 parent f8bf44b commit 2d76ef0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 25 deletions.
2 changes: 0 additions & 2 deletions src/libstore/remote-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(

try {
conn->to.written = 0;
conn->to.warn = true;
connections->incCapacity();
{
Finally cleanup([&]() { connections->decCapacity(); });
Expand All @@ -591,7 +590,6 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
dumpString(contents, conn->to);
}
}
conn->to.warn = false;
conn.processStderr();
} catch (SysError & e) {
/* Daemon closed while we were sending the path. Probably OOM
Expand Down
20 changes: 0 additions & 20 deletions src/libutil/serialise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,9 @@ FdSink::~FdSink()
}


size_t threshold = 256 * 1024 * 1024;

static void warnLargeDump()
{
warn("dumping very large path (> 256 MiB); this may run out of memory");
}


void FdSink::write(std::string_view data)
{
written += data.size();
static bool warned = false;
if (warn && !warned) {
if (written > threshold) {
warnLargeDump();
warned = true;
}
}
try {
writeFull(fd, data);
} catch (SysError & e) {
Expand Down Expand Up @@ -448,11 +433,6 @@ Error readError(Source & source)

void StringSink::operator () (std::string_view data)
{
static bool warned = false;
if (!warned && s.size() > threshold) {
warnLargeDump();
warned = true;
}
s.append(data);
}

Expand Down
4 changes: 1 addition & 3 deletions src/libutil/serialise.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,17 @@ protected:
struct FdSink : BufferedSink
{
int fd;
bool warn = false;
size_t written = 0;

FdSink() : fd(-1) { }
FdSink(int fd) : fd(fd) { }
FdSink(FdSink&&) = default;

FdSink& operator=(FdSink && s)
FdSink & operator=(FdSink && s)
{
flush();
fd = s.fd;
s.fd = -1;
warn = s.warn;
written = s.written;
return *this;
}
Expand Down

0 comments on commit 2d76ef0

Please sign in to comment.