git.iko.soy/typeable/cabal2nix
on v2.4 help sign in
typeable/cabal2nix/doc/04-set-up-a-sufficiently-powerful-build-farm.md
208 lines 8.7 kB history raw
1Set up a Sufficiently Powerful Build Farm
2=========================================
4The Problem
5-----------
7`hydra.nixos.org` compiles and provides binaries only for the `haskellPackages`
8package set. The build farm compiles none of our LTS Haskell package sets,
9which means that users of `haskell.packages.lts-x_y` cannot get any
10pre-compiled binaries. It also means that those builds aren't verified, i.e. we
11won't notice when changes to Nixpkgs break builds in those package sets.
13Furthermore, we have [no pre-compiled binaries with profiling support][1] for
14any of our package sets.
16The Situation Today
17-------------------
19We have 66 active package sets that define the following number of active
20builds per platform:
22 pkgset builds
23 1: ghc6123 5173
24 2: ghc704 5182
25 3: ghc7102 5189
26 4: ghc722 5183
27 5: ghc742 5183
28 6: ghc763 5182
29 7: ghc783 5173
30 8: ghc784 5173
31 9: ghcHEAD 5188
32 10: ghcNokinds 5188
33 11: ghcjs 5172
34 12: lts-0_0 795
35 13: lts-0_1 795
36 14: lts-0_2 795
37 15: lts-0_3 795
38 16: lts-0_4 795
39 17: lts-0_5 795
40 18: lts-0_6 795
41 19: lts-0_7 795
42 20: lts-1_0 827
43 21: lts-1_1 827
44 22: lts-1_10 828
45 23: lts-1_11 829
46 24: lts-1_12 829
47 25: lts-1_13 829
48 26: lts-1_14 830
49 27: lts-1_15 831
50 28: lts-1_2 828
51 29: lts-1_4 828
52 30: lts-1_5 828
53 31: lts-1_7 828
54 32: lts-1_8 828
55 33: lts-1_9 827
56 34: lts-2_0 1019
57 35: lts-2_1 1019
58 36: lts-2_10 1023
59 37: lts-2_11 1023
60 38: lts-2_12 1023
61 39: lts-2_13 1022
62 40: lts-2_14 1022
63 41: lts-2_15 1022
64 42: lts-2_16 1022
65 43: lts-2_17 1023
66 44: lts-2_18 1022
67 45: lts-2_19 1022
68 46: lts-2_2 1018
69 47: lts-2_20 1024
70 48: lts-2_21 1023
71 49: lts-2_22 1023
72 50: lts-2_3 1018
73 51: lts-2_4 1018
74 52: lts-2_5 1018
75 53: lts-2_6 1017
76 54: lts-2_7 1017
77 55: lts-2_8 1023
78 56: lts-2_9 1023
79 57: lts-3_0 1322
80 58: lts-3_1 1322
81 59: lts-3_2 1321
82 60: lts-3_3 1321
83 61: lts-3_4 1321
84 62: lts-3_5 1322
85 63: lts-3_6 1321
86 64: lts-3_7 1323
87 65: lts-3_8 1323
88 66: lts-3_9 1324
89 pkgset builds
91That gives a total of 111,647 active builds, many of which are identical. All
92package sets combined define 77,445 distinct store paths, i.e. some 34,202
93builds are shared across package sets.
95Now, `hydra.nixos.org` compiles only `haskellPackages` at the moment. Out of a
96total of [46,862 builds in trunk][2], 15,446 (33%) come from the Haskell
97package set. If we'd enable every Haskell package set on Linux/i686,
98Linux/x86_64, and Darwin/x86_64, then we'd have a total of 263,751 builds ---
995.6 times as much as before ---, and 88% of all builds would be related to
100Haskell.
102A complete build of the active derivations in `haskellPackages` takes up
103approx. 27 GByte of disk space per platform. That gives about 80 GByte for all
104of our 3 active platforms. How would that number develop if we'd enable
105everything? The store path sizes in MByte are distributed as follows (based on
1067,620 samples excluding `ghc`):
108 Minimum 1st Quart. Median Mean 3rd Quart. Maximum
109 0.0169 0.3557 0.9497 4.6300 3.0640 678.9000
111Multiplying the average store path size by the number of distinct store paths
112tells us that storing *everything* requires approx. 360 GByte per platform.
113With 3 active platforms, we'd need about 1 TByte of disk space for one complete
114set of Haskell packages.
116Now, we might be able to reduce that number by disabling some particularly
117large builds. The store path size distribution is skewed to the left, i.e.
118towards smaller builds. Approximately 82% of all store paths are actually
119smaller than the numerical average. Our top-20 biggest Haskell builds are:
121 pkg size
122 1: ghc 895.5
123 2: metadata 678.9
124 3: uhc-light 253.5
125 4: OpenGLRaw 249.3
126 5: FpMLv53 229.5
127 6: amazonka-ec2 214.8
128 7: Agda 212.6
129 8: xhb 189.0
130 9: unicode-properties 175.0
131 10: scholdoc-texmath 165.0
132 11: idris 137.7
133 12: gf 126.4
134 13: pandoc 124.8
135 14: unicode-names 118.4
136 15: wxcore 113.8
137 16: java-character 112.1
138 17: hat 111.1
139 18: texmath 109.6
140 19: open-symbology 107.6
141 20: turkish-deasciifier 104.0
143If we'd make an effort to disable some of those expensive builds --- or maybe
144reduce their output size ---, then we'd make a noticeable dent into the space
145requirements. Even so, it's clear that `hydra.nixos.org` cannot provide that
146much disk space today.
148Curiously enough, the CPU power necessary to compile all those packages is the
149least of our problems. Our build farm can easily re-compile everything from
150scratch within 2-3 days, which is "good enough" for all practical purposes.
151Also, changes to `stdenv` occur rarely (and we typically know about them in
152advance). The normal update cycle triggers only a handful of builds -- maybe
15320-300 per day --, because the versions fundamental Haskell packages are fixed
154in the LTS package sets.
156It's unclear whether the Hydra software would cope with 66 package sets with
157some 111,000 derivations in them that need to be evaluated, say, once an hour.
158Hydra has undergone some architectural changes recently that might make such a
159load possible --- i.e. `hydra-evaluator` is more efficient than it used to be
160---, but I don't have any reliable data concerning the performance of the
161process, so I cannot say what is possible and what is not.
163We know for sure that the currently available disk space doesn't suffice. Disk
164space is notoriously low on `hydra.nixos.org`, and storing another terabyte
165Haskell data is certainly impossible at the moment.
167Possible Improvements
168---------------------
170We have basically two alternatives:
1721. Throw hardware (money) at `hydra.nixos.org`.
1732. Establish a separate build farm for Haskell packages.
175Either solution requires money, which we could probably raise through crowd
176funding. At the moment, the NixOS Foundation collects donations for purposes of
177NixOS in general, but it should be possible to start a funding campaign that
178collects donations specifically for the purposes of establishing a Haskell
179build farm so that people who care about that particular topic have an
180incentive to participate.
182Now, if we'd go for approach (1), then we could use those funds to buy bigger
183disks and more RAM for `hydra.nixos.org`, which would be beneficial for
184everyone -- not just Haskell users. The downside is that `hydra.nixos.org` is a
185bit of a black box. Only very few people have access to those machines, and
186that situation is not going to change any time soon. Personally, I have no idea
187whether adding RAM or disks to the cluster is feasible at all, and whether
188those upgrades would enable the build farm to cope with the number of builds
189that we're considering here.
191Solution (2) seems more manageable, because we could set up an environment from
192scratch as we see fit. Experience from managing `hydra.cryp.to` suggests that
193one powerful KVM-based virtual server can serve as the Hydra master. In
194addition, we'd need 2-3 additional build slaves to compile packages. For
195massive re-builds, we could spawn another 10-15 builds slaves in EC2 to reduce
196the time it takes to re-build everything from scratch. Such a setup would
197probably work well in practice, and it should be available at a yearly cost of
1981,000 dollars or less.
200Anyhow, that's just a rough estimate. I don't know, really, what an ideal
201hardware / service platform for running such a virtual service would be. It
202would be great if a resident virtual server / NAS / system management guru
203could chime in with suggestions; I'm sure the NixOS crowd has people who know
204that kind of stuff and who can design the infrastructure for such a build farm.
207[1]: https://github.com/NixOS/nixpkgs/issues/10143
208[2]: http://hydra.nixos.org/jobset/nixpkgs/trunk