Skip to content

Commit

Permalink
Add SSHMaster::Connection::trySetBufferSize
Browse files Browse the repository at this point in the history
It is unused in Nix currently, but will be used in Hydra. This reflects
what Hydra does in NixOS/hydra#1387.

We may probalby to use it more widely for better SSH store performance,
but this needs to be subject to more testing before we do that.
  • Loading branch information
Ericson2314 committed May 26, 2024
1 parent 7de033d commit 05be135
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstore/ssh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,14 @@ Path SSHMaster::startMaster()

#endif

void SSHMaster::Connection::trySetBufferSize(size_t size)
{
#ifdef F_SETPIPE_SZ
// convert type
int pipesize = size;
fcntl(in.get(), F_SETPIPE_SZ, pipesize);
fcntl(out.get(), F_SETPIPE_SZ, pipesize);
#endif
}

}
10 changes: 10 additions & 0 deletions src/libstore/ssh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public:
Pid sshPid;
#endif
AutoCloseFD out, in;

/**
* Try to set the buffer size in both directions to the
* designated amount, if possible. If not possible, does
* nothing.
*
* Current implementation is to use `fcntl` with `F_SETPIPE_SZ`,
* which is Linux-only.
*/
void trySetBufferSize(size_t size);
};

/**
Expand Down

0 comments on commit 05be135

Please sign in to comment.