1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 00:11:17 +02:00

Make LocalBinaryCacheStore::narFromPath() run in constant memory

This reduces memory consumption of

  nix copy --from file://... --to ~/my-nix /nix/store/95cwv4q54dc6giaqv6q6p4r02ia2km35-blender-2.79

from 514 MiB to 18 MiB for an uncompressed binary cache, and from 192
MiB to 53 MiB for a bzipped binary cache. It may also be faster
because fetching can happen concurrently with decompression/writing.

Continuation of 48662d151b.

Issue https://github.com/NixOS/nix/issues/1681.
This commit is contained in:
Eelco Dolstra 2018-03-27 23:12:31 +02:00
parent 81ea8bd5ce
commit 08ec757726
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
6 changed files with 65 additions and 31 deletions

View file

@ -38,10 +38,16 @@ public:
const std::string & data,
const std::string & mimeType) = 0;
/* Return the contents of the specified file, or null if it
doesn't exist. */
/* Note: subclasses must implement at least one of the two
following getFile() methods. */
/* Dump the contents of the specified file to a sink. */
virtual void getFile(const std::string & path, Sink & sink);
/* Fetch the specified file and call the specified callback with
the result. A subclass may implement this asynchronously. */
virtual void getFile(const std::string & path,
Callback<std::shared_ptr<std::string>> callback) = 0;
Callback<std::shared_ptr<std::string>> callback);
std::shared_ptr<std::string> getFile(const std::string & path);
@ -129,4 +135,6 @@ public:
};
MakeError(NoSuchBinaryCacheFile, Error);
}