-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh.nix
77 lines (65 loc) · 2.17 KB
/
mesh.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
buildBazelPackage,
buildPackages,
fetchFromGitHub,
lib,
}:
buildBazelPackage {
strictDeps = true;
pname = "mesh";
version = "0-unstable-2024-07-06";
src = fetchFromGitHub {
owner = "plasma-umass";
repo = "Mesh";
rev = "d45d6deec627b7d46de98dfb5415c30b7c1db9c6";
hash = "sha256-fVph5EkQusbDVtZK5kLCqoW9EDyy2v1ACUe7QzrksTw=";
};
fetchAttrs.hash = "sha256-IZBQ1ICxOBo1p9JDNJsbdYyAvVqTnIRu510SibSk79g=";
bazel = buildPackages.bazel_5;
bazelBuildFlags = [
"--config=modern-amd64"
"--compilation_mode=opt"
];
bazelTargets = [ "//src:mesh" ];
removeRulesCC = false;
removeLocalConfigCC = false;
postPatch =
''
rm -f .bazelversion
rm -f ./tools/bazel
rm -f ./bazel
''
# Increase the arena size to 128 GB.
# --replace-fail \
# 'kArenaSize = 64ULL * 1024ULL * 1024ULL * 1024ULL; // 64 GB' \
# 'kArenaSize = 1024ULL * 1024ULL * 1024ULL * 1024ULL; // 1024 GB' \
# --replace-fail \
# 'static constexpr double kMeshesPerMap = .33;' \
# 'static constexpr double kMeshesPerMap = .0001;' \
+ ''
substituteInPlace ./src/common.h \
--replace-fail \
'static constexpr size_t kMinArenaExpansion = 4096; // 16 MB in pages' \
'static constexpr size_t kMinArenaExpansion = 2048; // 8 MB in pages'
substituteInPlace ./src/runtime.cc \
--replace-fail \
'const auto meshCount = static_cast<size_t>(kMeshesPerMap * mapCount);' \
'const auto meshCount = static_cast<size_t>(kMeshesPerMap * 1048576.0);'
'';
buildAttrs.installPhase = ''
runHook preInstall
mkdir -p "$out/lib"
install -c -m 0755 bazel-bin/src/libmesh.so "$out/lib/libmesh.so"
mkdir -p "$out/include/plasma"
install -c -m 0755 src/plasma/mesh.h "$out/include/plasma/mesh.h"
runHook postInstall
'';
doCheck = false;
meta = {
description = "A memory allocator that automatically reduces the memory footprint of C/C++ applications";
homepage = "https://github.com/plasma-umass/Mesh";
license = lib.licenses.asl20;
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [ connorbaker ];
};
}