# rework package manager · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/88bbec8f9b2f8f023a0177c204f51b8ac0aee83a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 88bbec8f9b2f8f023a0177c204f51b8ac0aee83a

Requested commit: 88bbec8f9b2f8f023a0177c204f51b8ac0aee83a

Commit: 88bbec8f9b2f8f023a0177c204f51b8ac0aee83a

Tree: 57d646f36e131b7ac61c244ca4b4a22dbb0d9a33

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
rework package manager

Organize everything around a Fetch task which does a bunch of stuff in a
worker thread without touching any shared state, and then queues up
Fetch tasks for its dependencies.

This isn't the theoretical optimal package fetching performance because
CPU cores don't necessarily map 1:1 with I/O tasks, and each fetch task
contains a mixture of computations and I/O. However, it is expected for
this to significantly outperform master branch, which fetches everything
recursively with only one thread.

The logic is now a lot more linear and easy to follow. Everything that
is embarassingly parallel is done on the thread pool, and then after
everything is fetched, the worker threads are joined and the main thread
does the finishing touches of stitching together the dependencies.zig
import files. There is only one tiny little critical section and it does
not even have any error handling in it.

This also lays the groundwork for #14281 because in system mode, all
this fetching logic will be skipped, but the "finishing touches"
mentioned above still need to be done. With this branch, that logic is
separated out and no longer recursively tangled with fetching stuff.

Additionally, this branch:
 * Implements inclusion directives in `build.zig.zon` for deciding which
   files belong the package (#14311).
 * Adds basic documentation for `build.zig.zon` files.
 * Adds support for fetching dependencies with the `file://` protocol
   scheme (#17364).
 * Adds a workaround for a Linux/btrfs file system bug (#17282).

This commit is a work-in-progress. Still todo:

1. Hook up the CLI to the new system.
2. Restore the module table creation logic after all the fetching is
   done.
3. Fix compilation errors, get the tests passing, and regression test
   against real world projects.

```

## Parents

- [d06da958846330ce7c40cf9c9fde1f9799cd30dd](https://git.cafe/gitcafe/zig/commit/d06da958846330ce7c40cf9c9fde1f9799cd30dd?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/88bbec8f9b2f8f023a0177c204f51b8ac0aee83a?format=markdown)
