Skip to content

Commit 235ba41

Browse files
committed
default chunk size is filesize/(nr_conn*4) (Issue #20)
and clean-up chunk_sz related parts.
1 parent 675126a commit 235ba41

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

doc/mscp.1.in

+5-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ parallel. The default value is 16M bytes.
198198
.TP
199199
.B \-S \fIMAX_CHUNK_SIZE\fR
200200
Specifies the maximum chunk size. The default is file size divided by
201-
the number of connections.
201+
the number of connections and devided by 4. If the calculated value
202+
is smarller than the
203+
.B MIN_CHUNK_SIZE
204+
value,
205+
MIN_CHUNK_SIZE is used.
202206

203207
.TP
204208
.B \-a \fINR_AHEAD\fR

doc/mscp.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MSCP
33
====
44

5-
:Date: v0.2.0-8-gef2dd55
5+
:Date: v0.2.0-9-g675126a
66

77
NAME
88
====
@@ -102,7 +102,9 @@ OPTIONS
102102

103103
**-S MAX_CHUNK_SIZE**
104104
Specifies the maximum chunk size. The default is file size divided by
105-
the number of connections.
105+
the number of connections and devided by 4. If the calculated value
106+
is smarller than the **MIN_CHUNK_SIZE** value, MIN_CHUNK_SIZE is
107+
used.
106108

107109
**-a NR_AHEAD**
108110
Specifies the number of inflight SFTP commands. The default value is

src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void usage(bool print_help)
4747
" -R CHECKPOINT resume transferring from the checkpoint\n"
4848
"\n"
4949
" -s MIN_CHUNK_SIZE min chunk size (default: 16M bytes)\n"
50-
" -S MAX_CHUNK_SIZE max chunk size (default: filesize/nr_conn)\n"
50+
" -S MAX_CHUNK_SIZE max chunk size (default: filesize/nr_conn/4)\n"
5151
" -a NR_AHEAD number of inflight SFTP commands (default: 32)\n"
5252
" -b BUF_SZ buffer size for i/o and transfer\n"
5353
" -L LIMIT_BITRATE Limit the bitrate, n[KMG] (default: 0, no limit)\n"

src/mscp.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,10 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path)
330330
return 0;
331331
}
332332

333-
static int get_page_mask(void)
333+
static size_t get_page_mask(void)
334334
{
335-
long page_sz = sysconf(_SC_PAGESIZE);
336-
size_t page_mask = 0;
337-
int n;
338-
339-
for (n = 0; page_sz > 0; page_sz >>= 1, n++) {
340-
page_mask <<= 1;
341-
page_mask |= 1;
342-
}
343-
344-
return page_mask >> 1;
335+
size_t page_sz = sysconf(_SC_PAGESIZE);
336+
return ~(page_sz - 1);
345337
}
346338

347339
static void mscp_stop_copy_thread(struct mscp *m)

src/path.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,10 @@ static int resolve_chunk(struct path *p, size_t size, struct path_resolve_args *
102102
size_t chunk_sz, off, len;
103103
size_t remaind;
104104

105-
if (size <= a->min_chunk_sz)
106-
chunk_sz = size;
107-
else if (a->max_chunk_sz)
105+
if (a->max_chunk_sz)
108106
chunk_sz = a->max_chunk_sz;
109107
else {
110-
chunk_sz = (size - (size % a->nr_conn)) / a->nr_conn;
111-
chunk_sz &= ~a->chunk_align; /* align with page_sz */
108+
chunk_sz = (size / (a->nr_conn * 4)) & a->chunk_align;
112109
if (chunk_sz <= a->min_chunk_sz)
113110
chunk_sz = a->min_chunk_sz;
114111
}

0 commit comments

Comments
 (0)