<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/12 Liu Yuan <span dir="ltr"><<a href="mailto:namei.unix@gmail.com" target="_blank">namei.unix@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- make the max of buffer size as 1000MB (reason inlined in the source)<br>
- allocate the buffer size based on the request length<br>
<br>
Signed-off-by: Liu Yuan <<a href="mailto:namei.unix@gmail.com">namei.unix@gmail.com</a>><br>
---<br>
sheep/http/kv.c | 16 +++++++++++-----<br>
1 file changed, 11 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/sheep/http/kv.c b/sheep/http/kv.c<br>
index dd5ca56..6c73d30 100644<br>
--- a/sheep/http/kv.c<br>
+++ b/sheep/http/kv.c<br>
@@ -673,7 +673,11 @@ static int vdi_read_write(uint32_t vid, char *data, size_t length,<br>
return local_req_wait(iocb);<br>
}<br>
<br>
-#define READ_WRITE_BUFFER (SD_DATA_OBJ_SIZE * 25) /* no rationale */<br>
+/*<br>
+ * For a 10Gb NIC, we have bandwidth over 1000 MB/s, so we can have this as the<br>
+ * upper limit for PUT/GET bandwidth.<br>
+ */<br>
+#define MAX_RW_BUFFER (SD_DATA_OBJ_SIZE * 250)<br></blockquote><div><br></div><div>I think 1GB buffer is too large for some old computer.</div><div>And , 1GB buffer is not the essential precondition for reaching the bandwidth of 1000 MB/s</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
static int onode_populate_extents(struct kv_onode *onode,<br>
struct http_request *req)<br>
@@ -683,6 +687,7 @@ static int onode_populate_extents(struct kv_onode *onode,<br>
int ret;<br>
char *data_buf = NULL;<br>
uint32_t data_vid = onode->data_vid;<br>
+ uint64_t write_buffer_size = MIN(MAX_RW_BUFFER, req->data_length);<br>
<br>
count = DIV_ROUND_UP(req->data_length, SD_DATA_OBJ_SIZE);<br>
sys->cdrv->lock(data_vid);<br>
@@ -694,11 +699,11 @@ static int onode_populate_extents(struct kv_onode *onode,<br>
goto out;<br>
}<br>
<br>
- data_buf = xmalloc(READ_WRITE_BUFFER);<br>
+ data_buf = xmalloc(write_buffer_size);<br>
offset = start * SD_DATA_OBJ_SIZE;<br>
total = req->data_length;<br>
while (done < total) {<br>
- size = http_request_read(req, data_buf, READ_WRITE_BUFFER);<br>
+ size = http_request_read(req, data_buf, write_buffer_size);<br>
ret = vdi_read_write(data_vid, data_buf, size, offset, false);<br>
if (ret != SD_RES_SUCCESS) {<br>
sd_err("Failed to write data object for %s, %s",<br>
@@ -863,15 +868,16 @@ static int onode_read_extents(struct kv_onode *onode, struct http_request *req)<br>
uint64_t size, total, total_size, offset, done = 0, i;<br>
int ret;<br>
char *data_buf = NULL;<br>
+ uint64_t read_buffer_size = MIN(MAX_RW_BUFFER, onode->size);<br>
<br>
- data_buf = xmalloc(READ_WRITE_BUFFER);<br>
+ data_buf = xmalloc(read_buffer_size);<br>
total_size = onode->size;<br>
for (i = 0; i < onode->nr_extent; i++) {<br>
ext = onode->o_extent + i;<br>
total = min(ext->count * SD_DATA_OBJ_SIZE, total_size);<br>
offset = ext->start * SD_DATA_OBJ_SIZE;<br>
while (done < total) {<br>
- size = MIN(total - done, READ_WRITE_BUFFER);<br>
+ size = MIN(total - done, read_buffer_size);<br>
ret = vdi_read_write(onode->data_vid, data_buf,<br>
size, offset, true);<br>
if (ret != SD_RES_SUCCESS) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.2<br>
<br>
--<br>
sheepdog mailing list<br>
<a href="mailto:sheepdog@lists.wpkg.org">sheepdog@lists.wpkg.org</a><br>
<a href="http://lists.wpkg.org/mailman/listinfo/sheepdog" target="_blank">http://lists.wpkg.org/mailman/listinfo/sheepdog</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Best Regard<br>Robin Dong
</div></div>