diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-12-01 22:53:37 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-12-01 23:35:10 +0100 |
| commit | 9a8f9f84cc1672c45c2d204d9c234c932a8cb623 (patch) | |
| tree | e900669630be57c9f5eac6081b3b903afd674db9 /nix/nix-daemon | |
| parent | 0b72475301e20521e0dd9fc22881eaab4a7fe170 (diff) | |
daemon: Buffer data sent to clients by the 'export-path' RPC.
Before that we'd have STDERR_WRITE round trips for very small amounts of
data, ranging from a few bytes for the metadata of nars to the size of
one file being exported.
With this change, something like:
guix archive --export /gnu/store/5rrsbaghh5ix1vjcicsl60gsxilhjnf2-coreutils-8.25 | dd of=/dev/null
reports a throughput of 35 MB/s instead of 25 MB/s before.
* nix/nix-daemon/nix-daemon.cc (TunnelSink): Inherit from 'BufferedSink'
rather than 'Sink'. Rename 'operator ()' to 'write'.
(performOp) <wopExportPath>: Add 'sink.flush' call.
Diffstat (limited to 'nix/nix-daemon')
| -rw-r--r-- | nix/nix-daemon/nix-daemon.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 9b29b3e91d3..682f9a2b5ba 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc | |||
| @@ -203,11 +203,11 @@ static void stopWork(bool success = true, const string & msg = "", unsigned int | |||
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | 205 | ||
| 206 | struct TunnelSink : Sink | 206 | struct TunnelSink : BufferedSink |
| 207 | { | 207 | { |
| 208 | Sink & to; | 208 | Sink & to; |
| 209 | TunnelSink(Sink & to) : to(to) { } | 209 | TunnelSink(Sink & to) : BufferedSink(64 * 1024), to(to) { } |
| 210 | virtual void operator () (const unsigned char * data, size_t len) | 210 | virtual void write(const unsigned char * data, size_t len) |
| 211 | { | 211 | { |
| 212 | writeInt(STDERR_WRITE, to); | 212 | writeInt(STDERR_WRITE, to); |
| 213 | writeString(data, len, to); | 213 | writeString(data, len, to); |
| @@ -433,6 +433,7 @@ static void performOp(bool trusted, unsigned int clientVersion, | |||
| 433 | startWork(); | 433 | startWork(); |
| 434 | TunnelSink sink(to); | 434 | TunnelSink sink(to); |
| 435 | store->exportPath(path, sign, sink); | 435 | store->exportPath(path, sign, sink); |
| 436 | sink.flush(); | ||
| 436 | stopWork(); | 437 | stopWork(); |
| 437 | writeInt(1, to); | 438 | writeInt(1, to); |
| 438 | break; | 439 | break; |
