From 0f59eef9a7844f4e786fb2ed81caeb00d5bb9d55 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 16 Jul 2009 19:41:56 +0000 Subject: [PATCH] - client: changed file upload logic Old: each upload attempt consists of two HTTP requests: the 1st to get the current file size on server, the 2nd to upload the remainder of the file. Problem: a) if the upload server is overloaded and requests are succeeding with probability X, then the chance of both requests succeeding is X^2. So e.g. a per-request success rate of 0.1 becomes an overall success rate of 0.01. b) the "get file size" request can be avoided in some cases. New: If we've already queried the file size and haven't uploaded any additional bytes, don't query the file size again. svn path=/trunk/boinc/; revision=18605 --- checkin_notes | 20 ++++++++++++++++++++ client/pers_file_xfer.cpp | 9 ++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index 869c368884..f7e08f1329 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6303,3 +6303,23 @@ David 16 July 2009 lib/ gui_rpc_client_ops.cpp gui_rpc_client.h + +David 16 July 2009 + - client: changed file upload logic + Old: each upload attempt consists of two HTTP requests: + the 1st to get the current file size on server, + the 2nd to upload the remainder of the file. + Problem: + a) if the upload server is overloaded and requests + are succeeding with probability X, + then the chance of both requests succeeding is X^2. + So e.g. a per-request success rate of 0.1 + becomes an overall success rate of 0.01. + b) the "get file size" request can be avoided in some cases. + New: + If we've already queried the file size + and haven't uploaded any additional bytes, + don't query the file size again. + + client/ + pers_file_xfer.cpp diff --git a/client/pers_file_xfer.cpp b/client/pers_file_xfer.cpp index d9c4b60517..0891433fe7 100644 --- a/client/pers_file_xfer.cpp +++ b/client/pers_file_xfer.cpp @@ -191,7 +191,6 @@ bool PERS_FILE_XFER::poll() { return false; } last_time = gstate.now; - fip->upload_offset = -1; retval = create_xfer(); return (retval == 0); } @@ -269,6 +268,14 @@ bool PERS_FILE_XFER::poll() { transient_failure(fxp->file_xfer_retval); } + // If we transferred any bytes, set upload_offset back to -1 + // so that we'll query file size on next retry. + // Otherwise leave it as is, avoiding unnecessary size query. + // + if (fxp->bytes_xferred) { + fip->upload_offset = -1; + } + // fxp could have already been freed and zeroed above // so check before trying to remove //