Re: [PATCH v2 05/20] insert: copy stdin to Maildir tmp file
authorPeter Wang <novalazy@gmail.com>
Mon, 26 Nov 2012 12:05:05 +0000 (23:05 +1100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:01 +0000 (09:51 -0800)
51/be72b432008463cb17e55d340280693fd24a4c [new file with mode: 0644]

diff --git a/51/be72b432008463cb17e55d340280693fd24a4c b/51/be72b432008463cb17e55d340280693fd24a4c
new file mode 100644 (file)
index 0000000..7713a4d
--- /dev/null
@@ -0,0 +1,114 @@
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 57BED431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 04:05:15 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Nris0RKcXYEW for <notmuch@notmuchmail.org>;\r
+       Mon, 26 Nov 2012 04:05:13 -0800 (PST)\r
+Received: from mail-da0-f53.google.com (mail-da0-f53.google.com\r
+       [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 8FF6D431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 04:05:13 -0800 (PST)\r
+Received: by mail-da0-f53.google.com with SMTP id x6so2879236dac.26\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Nov 2012 04:05:11 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=date:message-id:from:to:cc:subject:in-reply-to:references\r
+       :mime-version:content-type:content-disposition\r
+       :content-transfer-encoding;\r
+       bh=WCtQ2ic/6gZmX8BLR4JP6EFuEHW5EAzDGumtAb1J9Jg=;\r
+       b=mG567wbtdaC3fa3VBr2UOTiDiCuKlkRff2Lp+amUo/Ay7TeiGYPsZJPswUgUtD2f7N\r
+       bRYBuoOgpX5Qxy81Hd3Hqv++/AtIhh80vhjtFlnKBmmrdm+fJPLfoozp9I39nxknp/Na\r
+       DYM8SBZXIo8vDl3yB/GSg3Nsh3ualWzdsa40zr0ZxfAGy+4/wQcrnos6H3zh338lWFSY\r
+       AmWsCVyBohVEQyek2xUGk9otvZw4CMh7UgwoWO5KTMl95UaM4896/iGZe2bhMez4Iqqr\r
+       Kq3Gum4RPST/e/qQ+hAUONHE1PEieVVDuw3eDvpdZXD4CRJ29FbxdF4g6SQiK0BaXOuQ\r
+       wTOQ==\r
+Received: by 10.66.87.42 with SMTP id u10mr25517846paz.62.1353931511628;\r
+       Mon, 26 Nov 2012 04:05:11 -0800 (PST)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPS id vk5sm8686958pbc.34.2012.11.26.04.05.08\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 26 Nov 2012 04:05:10 -0800 (PST)\r
+Date: Mon, 26 Nov 2012 23:05:05 +1100\r
+Message-ID: <20121126230505.GA2095@hili.localdomain>\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>\r
+Subject: Re: [PATCH v2 05/20] insert: copy stdin to Maildir tmp file\r
+In-Reply-To: <m2txscitya.fsf@guru.guru-group.fi>\r
+References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>\r
+       <1353806206-29133-6-git-send-email-novalazy@gmail.com>\r
+       <m2txscitya.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 26 Nov 2012 12:05:15 -0000\r
+\r
+On Mon, 26 Nov 2012 11:39:41 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+> On Sun, Nov 25 2012, Peter Wang <novalazy@gmail.com> wrote:\r
+> \r
+> > Read the new message from standard input into the Maildir tmp file.\r
+> > ---\r
+> \r
+> There are a few issues that gort my attention in this particular function:\r
+> \r
+> \r
+> >  notmuch-insert.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++----\r
+> >  1 file changed, 47 insertions(+), 4 deletions(-)\r
+> >\r
+> > diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+> > index 371fb47..88e8533 100644\r
+> > --- a/notmuch-insert.c\r
+> > +++ b/notmuch-insert.c\r
+> > @@ -94,6 +94,47 @@ maildir_open_tmp_file (void *ctx, const char *dir,\r
+> >      return fd;\r
+> >  }\r
+> >  \r
+> > +/* Copy the contents of fdin into fdout. */\r
+> > +static notmuch_bool_t\r
+> > +copy_fd_data (int fdin, int fdout)\r
+> > +{\r
+> > +    char buf[4096];\r
+> \r
+> Copying in 4k blocks is slow when at least when doing file to file copy.\r
+> Also socket buffers can often hold much more data. When reading from\r
+> network and saving to file (in low-load machine) this is OK, but otherwise\r
+> something like 64k buffer works better(*).\r
+> \r
+> (*) Now that I said it I have to measure this yet another time ;)\r
+\r
+I get up to a whopping 10 ms faster copy of a 100 MiB file by increasing\r
+the buffer size to 8192 bytes or more (standalone program, stdin to\r
+disk, no fsync, no xapian).  Feel free to fiddle with it after it's\r
+pushed, if you think it's worthwhile.\r
+\r
+> You're claiming in function name & and its description that this is more\r
+> "generic" copy function -- yet error message speaks about 'standard input'.\r
+\r
+I'll rename it.\r
+\r
+Peter\r