From 472ff1b8338fe277a00fe20483bd74ec0d38cae8 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 20 Jul 2024 21:05:19 +0200 Subject: libstore: keep Goal errors as unique_ptrs Error is pretty large, and most goals do not fail. this alone more than halves the size of Goal on x86_64-linux, from 720 bytes down to 344. in derived classes the difference is not as dramatic, but even the largest derived class (`LocalDerivationGoal`) loses almost 20% of its footprint Change-Id: Ifda8f94c81b6566eeb3e52d55d9796ec40c7bce8 --- src/libstore/build/entry-points.cc | 2 +- src/libstore/build/goal.cc | 2 +- src/libstore/build/goal.hh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstore') diff --git a/src/libstore/build/entry-points.cc b/src/libstore/build/entry-points.cc index d4bead28e..67236bb39 100644 --- a/src/libstore/build/entry-points.cc +++ b/src/libstore/build/entry-points.cc @@ -22,7 +22,7 @@ void Store::buildPaths(const std::vector & reqs, BuildMode buildMod if (ex) logError(i->ex->info()); else - ex = std::move(i->ex); + ex = std::move(*i->ex); } if (i->exitCode != Goal::ecSuccess) { if (auto i2 = dynamic_cast(i.get())) diff --git a/src/libstore/build/goal.cc b/src/libstore/build/goal.cc index 8f190cede..f4973efc9 100644 --- a/src/libstore/build/goal.cc +++ b/src/libstore/build/goal.cc @@ -78,7 +78,7 @@ void Goal::amDone(ExitCode result, std::optional ex) if (!waiters.empty()) logError(ex->info()); else - this->ex = std::move(*ex); + this->ex = std::make_unique(std::move(*ex)); } for (auto & i : waiters) { diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh index 930fe90da..d105c53cd 100644 --- a/src/libstore/build/goal.hh +++ b/src/libstore/build/goal.hh @@ -121,7 +121,7 @@ public: /** * Exception containing an error message, if any. */ - std::optional ex; + std::unique_ptr ex; Goal(Worker & worker, DerivedPath path) : worker(worker) -- cgit v1.2.3