{"thread":{"id":"2008","subject":"[PATCH] Limit the number of requests outstanding in ssh-fetch.","startedAt":"2005-10-04T04:24:55Z","lastAt":"2005-10-04T07:46:48Z","messageCount":3,"participants":["Daniel Barkalow","Dan Aloni","Stefan Roese"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9653","messageId":"Pine.LNX.4.63.0510040016110.23242@iabervon.org","threadId":"2008","inReplyTo":null,"subject":"[PATCH] Limit the number of requests outstanding in ssh-fetch.","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-10-04T04:24:55Z","receivedAt":"2005-10-04T04:24:55Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This completes fetches if there are more than 100 outstanding requests\nand there are more to prefetch.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n\nLightly tested; I reduced the limit to 5, and pulled a small tree \nsuccessfully with some of the requests being completed early. I didn't \nhave the test case to verify that a limit of 100 is sufficiently low, but \nhandwaving suggests that it should be.\n\n ssh-fetch.c |   28 +++++++++++++++++++++++++++-\n 1 files changed, 27 insertions(+), 1 deletions(-)\n\n528f784890df88a5c054913136bbc53b164ebb94\ndiff --git a/ssh-fetch.c b/ssh-fetch.c\n--- a/ssh-fetch.c\n+++ b/ssh-fetch.c\n@@ -36,12 +36,26 @@ static ssize_t force_write(int fd, void \n \treturn ret;\n }\n \n+static int prefetches = 0;\n+\n+static struct object_list *in_transit = NULL;\n+static struct object_list **end_of_transit = &in_transit;\n+\n void prefetch(unsigned char *sha1)\n {\n \tchar type = 'o';\n+\tstruct object_list *node;\n+\tif (prefetches > 100) {\n+\t\tfetch(in_transit->item->sha1);\n+\t}\n+\tnode = xmalloc(sizeof(struct object_list));\n+\tnode->next = NULL;\n+\tnode->item = lookup_unknown_object(sha1);\n+\t*end_of_transit = node;\n+\tend_of_transit = &node->next;\n \tforce_write(fd_out, &type, 1);\n \tforce_write(fd_out, sha1, 20);\n-\t//memcpy(requested + 20 * prefetches++, sha1, 20);\n+\tprefetches++;\n }\n \n static char conn_buf[4096];\n@@ -51,6 +65,18 @@ int fetch(unsigned char *sha1)\n {\n \tint ret;\n \tsigned char remote;\n+\tstruct object_list *temp;\n+\n+\tif (memcmp(sha1, in_transit->item->sha1, 20)) {\n+\t\t// we must have already fetched it to clean the queue\n+\t\treturn has_sha1_file(sha1) ? 0 : -1;\n+\t}\n+\tprefetches--;\n+\ttemp = in_transit;\n+\tin_transit = in_transit->next;\n+\tif (!in_transit)\n+\t\tend_of_transit = &in_transit;\n+\tfree(temp);\n \n \tif (conn_buf_posn) {\n \t\tremote = conn_buf[0];\n"},{"id":"9658","messageId":"20051004071638.GA23725@localdomain","threadId":"2008","inReplyTo":"Pine.LNX.4.63.0510040016110.23242@iabervon.org","subject":"Re: [PATCH] Limit the number of requests outstanding in ssh-fetch.","fromName":"Dan Aloni","fromEmail":"da-x@monatomic.org","sentAt":"2005-10-04T07:16:38Z","receivedAt":"2005-10-04T07:16:38Z","isPatch":true,"sender":{"key":"da-x@monatomic.org","avatar":null},"body":"On Tue, Oct 04, 2005 at 12:24:55AM -0400, Daniel Barkalow wrote:\n> This completes fetches if there are more than 100 outstanding requests\n> and there are more to prefetch.\n> \n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> ---\n> \n> Lightly tested; I reduced the limit to 5, and pulled a small tree \n> successfully with some of the requests being completed early. I didn't \n> have the test case to verify that a limit of 100 is sufficiently low, but \n> handwaving suggests that it should be.\n\nGood, it seems that your patch works alright with the local Linux complete \ndatabase fetch.\n\n-- \nDan Aloni\nda-x@monatomic.org, da-x@colinux.org, da-x@gmx.net\n"},{"id":"9662","messageId":"200510040946.49509.sr@denx.de","threadId":"2008","inReplyTo":"20051004071638.GA23725@localdomain","subject":"Re: [PATCH] Limit the number of requests outstanding in ssh-fetch.","fromName":"Stefan Roese","fromEmail":"sr@denx.de","sentAt":"2005-10-04T07:46:48Z","receivedAt":"2005-10-04T07:46:48Z","isPatch":true,"sender":{"key":"sr@denx.de","avatar":null},"body":"On Tuesday 04 October 2005 09:16, Dan Aloni wrote:\n> > Lightly tested; I reduced the limit to 5, and pulled a small tree\n> > successfully with some of the requests being completed early. I didn't\n> > have the test case to verify that a limit of 100 is sufficiently low, but\n> > handwaving suggests that it should be.\n>\n> Good, it seems that your patch works alright with the local Linux complete\n> database fetch.\n\nWorks for me too (on a big ssh fetch, which stalled always without this \npatch).\n\nBest regards,\nStefan\n"}]}