[PATCH] Improving sftp client performance
mouring at etoh.eviladmin.org
mouring at etoh.eviladmin.org
Sat Jan 5 02:36:23 EST 2002
No it was not in the CVS tree yet. There was still discussions as to the
implementation. I have a version that does not do more more then two
overlapping writes.
I'll have to take a look at your patch a little closer, but I worry about
attempting to optimize the number of writes/reads done in a single
sitting. This could feesable change per hardware, per network, etc. If
we want to go this way I really suggest we flesh out that defination using
-r. That way the user can optimize it for themselves. With -r 1 mimicing
the current behavior. Then set a default (2 - 4) if -r is not used.
Attached is my version of the upload patch.
--- ../../ssh/sftp-client.c Wed Dec 19 18:00:49 2001
+++ ../sftp-client.c Tue Dec 25 14:00:00 2001
@@ -813,7 +813,7 @@
int pflag)
{
int local_fd;
- u_int handle_len, id;
+ u_int handle_len, id, ackid;
u_int64_t offset;
char *handle;
Buffer msg;
@@ -861,6 +861,7 @@
return(-1);
}
+ ackid = id + 1;
/* Read from local and write to remote */
offset = 0;
for (;;) {
@@ -878,26 +879,30 @@
if (len == -1)
fatal("Couldn't read from \"%s\": %s", local_path,
strerror(errno));
- if (len == 0)
+
+ if (len != 0) {
+ buffer_clear(&msg);
+ buffer_put_char(&msg, SSH2_FXP_WRITE);
+ buffer_put_int(&msg, ++id);
+ buffer_put_string(&msg, handle, handle_len);
+ buffer_put_int64(&msg, offset);
+ buffer_put_string(&msg, data, len);
+ send_msg(fd_out, &msg);
+ debug3("Sent message SSH2_FXP_WRITE I:%d O:%llu S:%u",
+ id, (unsigned long long)offset, len);
+ } else if (ackid > id)
break;
- buffer_clear(&msg);
- buffer_put_char(&msg, SSH2_FXP_WRITE);
- buffer_put_int(&msg, ++id);
- buffer_put_string(&msg, handle, handle_len);
- buffer_put_int64(&msg, offset);
- buffer_put_string(&msg, data, len);
- send_msg(fd_out, &msg);
- debug3("Sent message SSH2_FXP_WRITE I:%d O:%llu S:%u",
- id, (unsigned long long)offset, len);
-
- status = get_status(fd_in, id);
- if (status != SSH2_FX_OK) {
- error("Couldn't write to remote file \"%s\": %s",
- remote_path, fx2txt(status));
- do_close(fd_in, fd_out, handle, handle_len);
- close(local_fd);
- goto done;
+ if (id > ackid || (len == 0 && id == ackid)) {
+ status = get_status(fd_in, ackid);
+ if (status != SSH2_FX_OK) {
+ error("Couldn't write to remote file \"%s\": %s",
+ remote_path, fx2txt(status));
+ do_close(fd_in, fd_out, handle, handle_len);
+ close(local_fd);
+ goto done;
+ }
+ ackid++;
}
debug3("In write loop, got %d offset %llu", len,
(unsigned long long)offset);
More information about the openssh-unix-dev
mailing list