From mboxrd@z Thu Jan 1 00:00:00 1970 From: Frank van der Linden Subject: Re: [PATCH] pygrub: make it work Date: Thu, 19 Feb 2009 12:01:16 -0700 Message-ID: <499DAC7C.4020607@Sun.COM> References: <200902191048.24789.Christoph.Egger@amd.com> <18845.39159.846108.995200@mariner.uk.xensource.com> <499DA204.5080408@Sun.COM> <18845.43184.961624.895118@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 Content-Transfer-Encoding: 7BIT Return-path: In-reply-to: <18845.43184.961624.895118@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: Christoph Egger , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Ian Jackson wrote: > > I think it would be better to have something that is the same > everywhere so I'd encourage you to resubmit without the special > casing (and I'll help fix it if it goes wrong). I don't have much time right now to test on Linux, but I'll see if I can. Maybe Christoph can too. > Yes, that's a good explanation of the new code. What seems to be > lacking is an explanation of what was wrong with the old code - ie, > what should go in the changeset comment. > The comments do explain what was wrong with the old code.. The old code had the following problems: 1) It was reading and writing data one byte at the time, leading to overhead. However, it's safe to try to read/write bigger chunks, since the filedescriptors are NDELAY. 2) Instead of checking len(outbuf) / len(inbuf) for writes, simply do not include those filedescriptors in the select if there is nothing to write. Otherwise, the loop would run around in circles: the select would find that the output filedescriptors were writeable, but then the loop code would find that it had nothing to write to them. In the next iteration, the write filedescs would still be writeable, so select returns immediately, but there would still be no data to write. Etc, etc. It was essentially a while (1) until there was actual data to write. A waste of CPU cycles. - Frank