Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4809D429E26 for ; Tue, 15 Nov 2011 08:48:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6m9Gjjrqrkxc for ; Tue, 15 Nov 2011 08:48:41 -0800 (PST) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7AF54429E21 for ; Tue, 15 Nov 2011 08:48:41 -0800 (PST) Received: by wyg19 with SMTP id 19so3955395wyg.26 for ; Tue, 15 Nov 2011 08:48:40 -0800 (PST) Received: by 10.180.105.102 with SMTP id gl6mr31210724wib.46.1321375720253; Tue, 15 Nov 2011 08:48:40 -0800 (PST) Received: from localhost ([109.131.148.49]) by mx.google.com with ESMTPS id n2sm14691483wiz.16.2011.11.15.08.48.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Nov 2011 08:48:39 -0800 (PST) From: Pieter Praet To: Austin Clements Subject: Re: [PATCH] emacs: Use a single buffer invisibility spec to fix quadratic search cost. In-Reply-To: <20111111052716.GU2658@mit.edu> References: <1320807328-13728-1-git-send-email-amdragon@mit.edu> <877h382jax.fsf@SSpaeth.de> <87d3czxsu9.fsf@praet.org> <20111111045341.GS2658@mit.edu> <20111111052716.GU2658@mit.edu> User-Agent: Notmuch/0.9+76~g2fd88e6 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Tue, 15 Nov 2011 17:47:46 +0100 Message-ID: <87d3ctjpsd.fsf@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: notmuch@notmuchmail.org, servilio X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2011 16:48:42 -0000 On Fri, 11 Nov 2011 00:27:16 -0500, Austin Clements wrote: > Quoth myself on Nov 10 at 11:53 pm: > > Quoth Pieter Praet on Nov 11 at 4:04 am: > > > I've tried getting some hard numbers using > > > > > > #+begin_src sh > > > time emacs --eval '(progn > > > (notmuch) > > > (notmuch-search "*") > > > (while (get-buffer-process (current-buffer)) > > > (sleep-for 0.1)) > > > (kill-emacs))' > > > #+end_src > > > > > > ... but the results vary wildly on subsequent runs. > > > > For me, this doesn't actually display the results buffer (though I > > don't know why not), which means it won't test this, since the problem > > lies in the Emacs redisplay logic. > > This may or may not actually be correct, but the following seems more > representative on my system: > > time emacs --eval '(progn > (notmuch) > (notmuch-search "*") > (while (get-buffer-process (current-buffer)) > (redisplay) > (sleep-for 0.1)) > (kill-emacs))' > Yup, that does the trick! These remained fairly consistent, even with both CPU cores enabled: | | SINGLE | DUAL | | | before | after | before | after | |------+-----------+-----------+-----------+-----------| | real | 0m34.560s | 0m31.829s | 0m30.784s | 0m26.587s | | user | 0m26.188s | 0m23.672s | 0m27.028s | 0m22.889s | | sys | 0m0.863s | 0m0.907s | 0m1.200s | 0m1.243s | > This at least displays the buffer. I also tried > (accept-process-output) instead of the (sleep-for 0.1), which clearly > behaved differently, but gave only slightly higher numbers. If I > timed just the search part, to exclude emacs start-up, I would have a > better idea of which more closely matches my manual measurements. Oddly enough... I ran some tests using `elp-instrument-package' and your `time-it' macro [1] to keep emacs init out of the equation, and both not only produced horribly fluctuating results (even with only a single CPU core enabled), but often took *longer* as well! I'm stumped... #+begin_src emacs-lisp (progn (require 'notmuch) (let ((elp-reset-after-results t)) (elp-instrument-package "notmuch") (notmuch-search "*") (while (get-buffer-process (current-buffer)) (redisplay) (sleep-for 0.1)) (elp-results))) #+end_src #+begin_src emacs-lisp (defmacro time-it (code) `(let ((start-time (get-internal-run-time))) ,code (float-time (time-subtract (get-internal-run-time) start-time)))) (require 'notmuch) (time-it (progn (notmuch-search "*") (while (get-buffer-process (current-buffer)) (redisplay) (sleep-for 0.1)))) #+end_src Peace -- Pieter [1] id:"20110713185721.GI25558@mit.edu"