Allow configuring the multipart threshold (#1562)

Also change default which improves write performance for files >= 25
MB and <= 5 GB, particularly over lossy networks.

Co-authored-by: Takeshi Nakatani <ggtakec@gmail.com>
This commit is contained in:
Andrew Gaul
2021-02-11 23:35:46 +09:00
committed by GitHub
parent 7f6fbb0021
commit 134a54b32f
3 changed files with 18 additions and 1 deletions

View File

@ -212,6 +212,10 @@ sets MB to ensure disk free space. This option means the threshold of free space
s3fs makes file for downloading, uploading and caching files.
If the disk free space is smaller than this value, s3fs do not use diskspace as possible in exchange for the performance.
.TP
\fB\-o\fR multipart_threshold (default="25")
threshold, in MB, to use multipart upload instead of
single-part. Must be at least 5 MB.
.TP
\fB\-o\fR singlepart_copy_limit (default="512")
maximum size, in MB, of a single-part copy before trying
multipart copy.

View File

@ -90,6 +90,7 @@ static bool is_ibm_iam_auth = false;
static bool is_use_xattr = false;
static bool is_use_session_token = false;
static bool create_bucket = false;
static off_t multipart_threshold = 25 * 1024 * 1024;
static int64_t singlepart_copy_limit = 512 * 1024 * 1024;
static bool is_specified_endpoint = false;
static int s3fs_init_deferred_exit_status = 0;
@ -726,7 +727,7 @@ int put_headers(const char* path, headers_t& meta, bool is_copy, bool update_mti
// get_object_attribute() returns error with initializing buf.
(void)get_object_attribute(path, &buf);
if(buf.st_size >= FIVE_GB && !nocopyapi && !nomultipart){
if(!nocopyapi && !nomultipart && buf.st_size >= multipart_threshold){
if(0 != (result = s3fscurl.MultipartHeadRequest(path, buf.st_size, meta, is_copy))){
return result;
}
@ -4518,6 +4519,14 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
FdManager::SetEnsureFreeDiskSpace(dfsize);
return 0;
}
if(is_prefix(arg, "multipart_threshold=")){
multipart_threshold = static_cast<int64_t>(cvt_strtoofft(strchr(arg, '=') + sizeof(char))) * 1024 * 1024;
if(multipart_threshold <= MIN_MULTIPART_SIZE){
S3FS_PRN_EXIT("multipart_threshold must be at least %lld, was: %lld", static_cast<long long>(MIN_MULTIPART_SIZE), static_cast<long long>(multipart_threshold));
return -1;
}
return 0;
}
if(is_prefix(arg, "singlepart_copy_limit=")){
singlepart_copy_limit = static_cast<int64_t>(cvt_strtoofft(strchr(arg, '=') + sizeof(char))) * 1024 * 1024;
return 0;

View File

@ -260,6 +260,10 @@ static const char help_string[] =
" space is smaller than this value, s3fs do not use diskspace\n"
" as possible in exchange for the performance.\n"
"\n"
" multipart_threshold (default=\"25\")\n"
" - threshold, in MB, to use multipart upload instead of\n"
" single-part. Must be at least 5 MB.\n"
"\n"
" singlepart_copy_limit (default=\"512\")\n"
" - maximum size, in MB, of a single-part copy before trying \n"
" multipart copy.\n"