|
19 | 19 | NativeLink is an extremely (blazingly?) fast and efficient build cache and
|
20 | 20 | remote executor for systems that communicate using the [Remote execution
|
21 | 21 | protocol](https://github.com/bazelbuild/remote-apis/blob/main/build/bazel/remote/execution/v2/remote_execution.proto) such as [Bazel](https://bazel.build), [Buck2](https://buck2.build), [Goma](https://chromium.googlesource.com/infra/goma/client/) and
|
22 |
| -[Reclient](https://github.com/bazelbuild/reclient). NativeLink powers over one billion requests per month for customers using the system for their production workloads. |
| 22 | +[Reclient](https://github.com/bazelbuild/reclient). NativeLink powers over one |
| 23 | +billion requests per month in production workloads. |
23 | 24 |
|
24 | 25 | Supports Unix-based operating systems and Windows.
|
25 | 26 |
|
26 |
| -## Getting Started with NativeLink |
| 27 | +## 🚀 Quickstart |
27 | 28 |
|
28 |
| -Below, you will find a few different options for getting started with NativeLink. |
| 29 | +The setups below are **production-grade** installations. See the |
| 30 | +[contribution docs](https://docs.nativelink.com/contribute/nix/) for |
| 31 | +instructions on how to build from source with [Bazel](https://docs.nativelink.com/contribute/bazel/), |
| 32 | +[Cargo](https://docs.nativelink.com/contribute/cargo/), and [Nix](https://docs.nativelink.com/contribute/nix/). |
29 | 33 |
|
30 |
| -## 🚀 Example Deployments |
| 34 | +### 📦 Prebuilt images |
31 | 35 |
|
32 |
| -You can find a few example deployments in the [deployment-examples directory](./deployment-examples). |
| 36 | +Fast to spin up, but currently limited to `x86_64` systems. See the [container |
| 37 | +registry](https://github.com/TraceMachina/nativelink/pkgs/container/nativelink) |
| 38 | +for all image tags and the [contribution docs](https://docs.nativelink.com/contribute/nix) |
| 39 | +for how to build the images yourself. |
33 | 40 |
|
34 |
| -### 📝 Clone the NativeLink repository |
35 |
| -1. Go to the [NativeLink](https://github.com/TraceMachina/nativelink) repository on GitHub. Clone the repository via SSH or HTTPS. In this example the repository is cloned via SSH: |
36 |
| -```bash |
37 |
| -git clone [email protected]:TraceMachina/nativelink.git |
38 |
| -``` |
39 |
| - |
40 |
| -### 📦 Installing with Cargo |
41 |
| - |
42 |
| -1. First install Rust, but skip to step 2 if you have it already. |
43 |
| -```bash |
44 |
| -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
45 |
| -``` |
46 |
| -2. Install NativeLink with Cargo. |
47 |
| -```bash |
48 |
| -cargo install --git https://github.com/TraceMachina/nativelink --tag v0.4.0 |
49 |
| -``` |
50 |
| - |
51 |
| -### ⚙️ Configure and 🦾 Start NativeLink |
52 |
| - |
53 |
| -The `nativelink` executable reads a JSON file as it's only parameter, |
54 |
| -`--config`. See [`nativelink-config`](./nativelink-config/examples/basic_cas.json) |
55 |
| -for more details and examples. |
| 41 | +**Linux x86_64** |
56 | 42 |
|
57 |
| -To grab the example in your current working directory, run: |
58 |
| - |
59 |
| -```bash |
60 |
| -curl -O https://raw.githubusercontent.com/TraceMachina/nativelink/main/nativelink-config/examples/basic_cas.json |
61 |
| - |
62 |
| -### you can modify the example above to replace the filesystem store with the memory store if you favor speed over data durability. |
63 |
| -nativelink basic_cas.json |
64 |
| -``` |
65 |
| - |
66 |
| -## 🧪 Evaluating NativeLink |
67 |
| - |
68 |
| -1. Once you've built NativeLink and have an instance running with the `basic_cas.json` configuration, launch a separate terminal session. |
69 |
| -2. Navigate to where you cloned the NativeLink repository: |
70 | 43 | ```bash
|
71 |
| -cd $HOME/nativelink |
72 |
| -``` |
73 |
| -3. In the new terminal, run the following command to connect the running server launched above to Bazel or another RBE client: |
74 |
| - |
75 |
| -```sh |
76 |
| -bazel test //... \ |
77 |
| - --remote_instance_name=main \ |
78 |
| - --remote_cache=grpc://127.0.0.1:50051 \ |
79 |
| - --remote_executor=grpc://127.0.0.1:50051 \ |
80 |
| - --remote_default_exec_properties=cpu_count=1 |
| 44 | +curl -O \ |
| 45 | + https://raw.githubusercontent.com/TraceMachina/nativelink/main/nativelink-config/examples/basic_cas.json |
| 46 | + |
| 47 | +# See https://github.com/TraceMachina/nativelink/pkgs/container/nativelink |
| 48 | +# to find the latest tag |
| 49 | +docker run \ |
| 50 | + -v $(pwd)/basic_cas.json:/config \ |
| 51 | + -p 50051 \ |
| 52 | + ghcr.io/tracemachina/nativelink:v0.4.0 |
81 | 53 | ```
|
82 | 54 |
|
83 |
| -For Windows PowerShell; |
| 55 | +**Windows x86_64** |
84 | 56 |
|
85 | 57 | ```powershell
|
86 |
| -bazel test //... ` |
87 |
| - --remote_instance_name=main ` |
88 |
| - --remote_cache=grpc://127.0.0.1:50051 ` |
89 |
| - --remote_executor=grpc://127.0.0.1:50051 ` |
90 |
| - --remote_default_exec_properties=cpu_count=1 |
91 |
| -``` |
92 |
| -This causes Bazel to run the commands through an all-in-one `CAS`, `scheduler` |
93 |
| -and `worker`. |
94 |
| - |
95 |
| -> [!WARNING] |
96 |
| -> If you're using MacOS, encountering errors is anticipated at this stage. Our team is actively working on enhancing support for executing remoteable Bazel builds with MacOS. For now, you can run with [Docker](https://github.com/blakehatch/nativelink/tree/main/deployment-examples/docker-compose) or a Linux virtual machine. If you have any questions, reach out on the [NativeLink](https://join.slack.com/t/nativelink/shared_invite/zt-2forhp5n9-L7dTD21nCSY9_IRteQvZmw) slack. |
97 |
| -
|
98 |
| -## How it Works |
99 |
| - |
100 |
| -This diagram is a high-level overview of the data flow in the NativeLink system. It refers to NativeLink concepts like Scheduler pool, Worker pool, and CAS rather than the cloud concepts like functions, compute nodes, and object storage to which they correspond. |
101 |
| - |
102 |
| -```mermaid |
103 |
| -sequenceDiagram |
104 |
| - participant build server (client) |
105 |
| - participant scheduler pool |
106 |
| - participant worker pool |
107 |
| - participant cas |
108 |
| - build server (client)->>scheduler pool: queue jobs |
109 |
| - scheduler pool->>worker pool: route jobs |
110 |
| - worker pool->>cas: upload artifacts |
111 |
| - worker pool->>scheduler pool: result download instructions |
112 |
| - scheduler pool->>build server (client): result download instructions |
113 |
| - cas->>build server (client): service queries |
114 |
| - build server (client)->>cas: service queries |
| 58 | +# Download the configuration file |
| 59 | +Invoke-WebRequest ` |
| 60 | + -Uri "https://raw.githubusercontent.com/TraceMachina/nativelink/main/nativelink-config/examples/basic_cas.json" ` |
| 61 | + -OutFile "basic_cas.json" |
| 62 | +
|
| 63 | +# Run the Docker container |
| 64 | +# Note: Adjust the path if the script is not run from the directory containing basic_cas.json |
| 65 | +docker run ` |
| 66 | + -v ${PWD}/basic_cas.json:/config ` |
| 67 | + -p 50051 ` |
| 68 | + ghcr.io/tracemachina/nativelink:v0.4.0 |
115 | 69 | ```
|
116 |
| -## ❄️ Installing with Nix |
117 | 70 |
|
118 |
| -**Installation requirements:** |
| 71 | +### ❄️ Raw executable with Nix |
119 | 72 |
|
120 |
| -* Nix with [flakes](https://nixos.wiki/wiki/Flakes) enabled |
| 73 | +Slower, since it's built from source, but more flexible and supports MacOS. |
| 74 | +Doesn't support native Windows, but works in WSL2. |
121 | 75 |
|
122 |
| -This build doesn't require cloning the repository, but you need to provide a |
123 |
| -configuration file, for instance the one at [`nativelink-config/examples/basic_cas.json`](./nativelink-config/examples/basic_cas.json). |
| 76 | +Make sure your Nix version is recent and supports flakes. For instance, install |
| 77 | +it via the [next-gen nix installer](https://github.com/NixOS/experimental-nix-installer). |
124 | 78 |
|
125 |
| -The following command builds and runs NativeLink in release (optimized) mode: |
| 79 | +> [!CAUTION] |
| 80 | +> Executables built for MacOS are dynamically linked against libraries from Nix |
| 81 | +> and won't work on systems that don't have these libraries present. |
126 | 82 |
|
127 |
| -```sh |
128 |
| -nix run github:TraceMachina/nativelink ./basic_cas.json |
129 |
| -``` |
| 83 | +**Linux, MacOS, WSL2** |
130 | 84 |
|
131 |
| -For use in production pin the executable to a specific revision: |
132 |
| - |
133 |
| -```sh |
134 |
| -nix run github:TraceMachina/nativelink/<revision> ./basic_cas.json |
135 | 85 | ```
|
| 86 | +curl -O \ |
| 87 | + https://raw.githubusercontent.com/TraceMachina/nativelink/main/nativelink-config/examples/basic_cas.json |
136 | 88 |
|
137 |
| -## 🌱 Building with Bazel |
138 |
| - |
139 |
| -**Build requirements:** |
140 |
| - |
141 |
| -* Bazel `7.0.2` |
142 |
| -* A recent C++ toolchain with LLD as linker |
143 |
| - |
144 |
| -> [!TIP] |
145 |
| -> This build supports Nix/direnv which provides Bazel but no C++ toolchain |
146 |
| -> (yet). |
147 |
| -
|
148 |
| -The following commands places an executable in `./bazel-bin/nativelink` and |
149 |
| -starts the service: |
150 |
| - |
151 |
| -```sh |
152 |
| -# Unoptimized development build on Unix |
153 |
| -bazel run nativelink -- $(pwd)/nativelink-config/examples/basic_cas.json |
154 |
| - |
155 |
| -# Optimized release build on Unix |
156 |
| -bazel run -c opt nativelink -- $(pwd)/nativelink-config/examples/basic_cas.json |
157 |
| - |
158 |
| -# Unoptimized development build on Windows |
159 |
| -bazel run --config=windows nativelink -- $(pwd)/nativelink-config/examples/basic_cas.json |
160 |
| - |
161 |
| -# Optimized release build on Windows |
162 |
| -bazel run --config=windows -c opt nativelink -- $(pwd)/nativelink-config/examples/basic_cas.json |
163 |
| -``` |
164 |
| - |
165 |
| -> [!WARNING] |
166 |
| -> The Rust compiler `rustc` generates numerous artifacts during compilation, |
167 |
| -> including dependencies, macros, and intermediate files. |
168 |
| -> When compiling programs from source, be mindful of the associated files' |
169 |
| -> impact on your disk usage in the `bazel-bin/` directory. |
170 |
| -> This directory can grow substantially in size. |
171 |
| -> |
172 |
| -> If the facing issues due to this, run the following command |
173 |
| -> to clear cache files: |
174 |
| -> ```sh |
175 |
| -> bazel clean --expunge |
176 |
| -> ``` |
177 |
| -
|
178 |
| -## 📦 Building with Cargo |
179 |
| -
|
180 |
| -**Build requirements:** |
181 |
| -
|
182 |
| -* Cargo 1.74.0+ |
183 |
| -* A recent C++ toolchain with LLD as linker |
184 |
| -
|
185 |
| -> [!TIP] |
186 |
| -> This build supports Nix/direnv which provides Cargo but no C++ |
187 |
| -> toolchain/stdenv (yet). |
188 |
| -
|
189 |
| -```bash |
190 |
| -# Unoptimized development build |
191 |
| -cargo run --bin nativelink -- ./nativelink-config/examples/basic_cas.json |
192 |
| -
|
193 |
| -# Optimized release build |
194 |
| -cargo run --release --bin nativelink -- ./nativelink-config/examples/basic_cas.json |
| 89 | +nix run github:TraceMachina/nativelink ./basic_cas.json |
195 | 90 | ```
|
196 | 91 |
|
197 |
| -> [!WARNING] |
198 |
| -> The Rust compiler `rustc` generates numerous artifacts during compilation, |
199 |
| -> including dependencies, macros, and intermediate files. |
200 |
| -> When compiling programs from source, be mindful of the associated files' |
201 |
| -> impact on your disk usage in the target/ directory. |
202 |
| -> This directory can grow substantially in size. |
203 |
| -> |
204 |
| -> If the facing issues due to this, run the following command |
205 |
| -> to clear cache files: |
206 |
| -> ```sh |
207 |
| -> cargo clean |
208 |
| -> ``` |
209 |
| -
|
210 |
| -## Project Health |
211 |
| -
|
212 |
| -* Powering more than 1 billion devices at the edge. |
213 |
| -
|
214 |
| -## 🏺 History |
215 |
| -
|
216 |
| -This project was first created due to frustration with similar projects not |
217 |
| -working or being extremely inefficient. Rust was chosen as the language to write |
218 |
| -it in because at the time Rust was going through a revolution in the new-ish |
219 |
| -feature `async-await`. This made making multi-threading simpler when |
220 |
| -paired with a runtime like [Tokio](https://github.com/tokio-rs/tokio) while |
221 |
| -still giving all the lifetime and other protections that Rust gives. This pretty |
222 |
| -much guarantees that we will never have crashes due to race conditions. This |
223 |
| -kind of project seemed perfect, since there is so much asynchronous activity |
224 |
| -happening and running them on different threads is most preferable. Other |
225 |
| -languages like `Go` are good candidates, but other similar projects rely heavily |
226 |
| -on channels and mutex locks which are cumbersome and have to be carefully |
227 |
| -designed by the developer. Rust doesn't have these issues, since the compiler |
228 |
| -will always tell you when the code you are writing might introduce undefined |
229 |
| -behavior. The last major reason is because Rust is extremely fast and has no |
230 |
| -garbage collection (like C++, but unlike `Java`, `Go`, or `Typescript`). |
| 92 | +See the [contribution docs](https://docs.nativelink.com/contribute/nix) for |
| 93 | +further information. |
231 | 94 |
|
232 | 95 | ## 📜 License
|
233 | 96 |
|
|
0 commit comments