support torrenting for fetching and serving packages #23236
Labels
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
zig build system
std.Build, the build runner, `zig build` subcommand, package management
Milestone
This idea builds upon
zig build --watch
mode where the build runner stays running for a long time, keeping a project's build graph up-to-date.The idea is to add a new flag,
-ftorrent
, which makes the build runner additionally fetch and serve packages in a decentralized manner.We could easily get away with using direct fetching only, so why bother with this?
Given there may be multiple instances of
zig build --watch
running, there are two ways this could work:Either way, all packages that are present on the system (i.e. in
~/.cache/zig/p
) would be seeded, unless the package hasprivate: true
in the build manifest. There is precedent for this in npm.One neat feature this brings to the table is that the most popular packages which are being used the most and therefore need to be fetched the most, end up being seeded the most. This also provides a nice popularity metric. To game the metric means donating extra bandwidth to the network, so go ahead and game the metric - everybody wins.
There are some settings which might be valuable to be stored persistently, such as:
-ftorrent
,-fno-torrent
).private: true
, having default on would be too aggressive. However, it would be nice if users could decide once to enable it and not have to remember to enable it with every CLI invocation.Figuring out whether and how to store persistent settings such as those is a separate issue.
Here are some ways this could work:
When nothing needs to be fetched, it might be worth doing a timeout before starting seeding since there could be a high likelihood of users starting and killing the process rapidly. On the other hand, the state could be maintained on disk such that doing so doesn't "reset" but rather only introduces latency.
The text was updated successfully, but these errors were encountered: