aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/platform.cc
diff options
context:
space:
mode:
authorArtemis Tosini <me@artem.ist>2024-03-29 20:29:44 -0400
committerArtemis Tosini <lix@artem.ist>2024-04-25 23:24:21 -0400
commitc03de0df627864fb7e83e9af88201b8a5fcd4930 (patch)
tree39b4b783a896199d736022422b29bf1be05b304f /src/libstore/platform.cc
parent5420b3afd6c328faf1508dce03bbe8e58da8af2b (diff)
gc: Find roots using libproc on Darwin
Previously, the garbage collector found runtime roots on Darwin by shelling out to `lsof -n -w -F n` then parsing the result. However, this requires an lsof binary and can be extremely slow. The official Apple lsof returns in a reasonable amount of time, about 250ms in my tests, but the lsof packaged in nixpkgs is quite slow, taking about 40 seconds to run the command. Using libproc directly is about the same speed as Apple lsof, and allows us to reënable several tests that were disabled on Darwin. Change-Id: Ifa0adda7984e13c15535693baba835aae79a3577
Diffstat (limited to 'src/libstore/platform.cc')
-rw-r--r--src/libstore/platform.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstore/platform.cc b/src/libstore/platform.cc
index 9c389ef55..acdedab99 100644
--- a/src/libstore/platform.cc
+++ b/src/libstore/platform.cc
@@ -2,6 +2,8 @@
#if __linux__
#include "platform/linux.hh"
+#elif __APPLE__
+#include "platform/darwin.hh"
#else
#include "platform/fallback.hh"
#endif
@@ -11,6 +13,8 @@ std::shared_ptr<LocalStore> LocalStore::makeLocalStore(const Params & params)
{
#if __linux__
return std::shared_ptr<LocalStore>(new LinuxLocalStore(params));
+#elif __APPLE__
+ return std::shared_ptr<LocalStore>(new DarwinLocalStore(params));
#else
return std::shared_ptr<LocalStore>(new FallbackLocalStore(params));
#endif