Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up the process of copying drv files to the remote host #62

Open
exarkun opened this issue Dec 9, 2021 · 1 comment
Open

Speed up the process of copying drv files to the remote host #62

exarkun opened this issue Dec 9, 2021 · 1 comment

Comments

@exarkun
Copy link
Contributor

exarkun commented Dec 9, 2021

Is your feature request related to a problem? Please describe.

When deploying changes with deploy_nixos a large portion of the deploy time is spent copying .drv files to the remote host. These files are very small, there are often very many of them, and round-trip latency ends up accounting for most of the time spent.

Describe the solution you'd like

According to #nixos on Matrix, the nix-copy-closure protocol is "very chatty" (ie, has many round-trips) because it tries not to send any objects that the remote already has and it tries not to send anything that the remote doesn't already have all dependencies for.

When buildOnTarget is set, deploy_nixos runs nix-copy-closure in nixos-deploy.sh specifically to copy derivations only. Instead of using nix-copy-closure in this case, it could perform an export, transfer the export, then perform an import. This would be a much less "chatty" exchange and largely eliminate the effects of round-trip latency. Since drvs are small, the penalty of possibly transferring some which do not need to be transferred is minimal. An entire NixOS system's drvs might amount to 30MB or 40MB.

This option could be guarded by a configuration toggle if there's some desire to put the choice about this trade-off into the end-user's hands.

Describe alternatives you've considered

None

Additional context

None

@exarkun
Copy link
Contributor Author

exarkun commented Dec 9, 2021

The export / import might somewhat resemble this pipeline:

nix-store --export $(nix-store --query --requisites $drvPath) | ssh remote nix-store --import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant