# CMake Parallel Build with All Cores

Recently, while trying to compile Traffic Server, came across very poor performance issues, turns out the build was only taking one core, and so in order to use all the cores on the system, we can use `-j` or `--parallel` to specify the number of jobs to run in parallel.

## Example

```bash
cmake --build build -j $(nproc --all)

# or

cmake --build build --parallel $(nproc --all)
```

**Note:** This will use up all the cores/threads on the system, which may mean the system becomes very slow, and laggy. So, one may choose to free up a CPU by using following command.

```bash
cmake --build build --parallel $(($(nproc --all) - 1))
```

***Source(s):***

* [StackOverFlow](https://stackoverflow.com/a/70552553)
* [StackOverFlow](https://stackoverflow.com/a/41691009)

***Reference:*** [***CMake - Documentation***](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-build-j)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/linux/cmake-parallel-build-with-all-cores.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
