From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] tags search: faster tags matcher by trusting scanner tags Date: Fri, 16 Mar 2012 11:35:47 +0100 Message-ID: <20695543-EDFE-417B-9EF6-63C54EC086D7@gmail.com> References: <3953.1331867583@alphaville> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:47042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8UXs-0008Ru-Lk for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 06:38:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8UXm-00076m-5k for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 06:38:04 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:38268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8UXl-00076e-T0 for emacs-orgmode@gnu.org; Fri, 16 Mar 2012 06:37:58 -0400 Received: by eaal1 with SMTP id l1so2252830eaa.0 for ; Fri, 16 Mar 2012 03:37:54 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ilya Shlyakhter Cc: nicholas.dokos@hp.com, emacs-orgmode Hi Ilya, hi Nick, thanks for looking into this. I am amazed by the deep understanding of Org's internals that shows in this thread. Both patches seem to be OK as far as I can see and can be applied without adverse effects. The patch for org-clock.el will at most achieve a factor of two (because org-get-tags-at is called anyway), but indeed, the patch in org.el can potentially have even more significant effects, when properties are tested in the matcher. Cheers and thanks! - Carsten On 16.3.2012, at 05:34, Ilya Shlyakhter wrote: > Here is a similar patch for org-clock's use of tags/properties = matcher. >=20 > On Fri, Mar 16, 2012 at 12:31 AM, Ilya Shlyakhter = wrote: > ,---- > | If your function needs to retrieve the tags including inherited tags > | at the *current* entry,=20 >=20 > 'Function' here refers to the FUNC parameter of org-map-entries, not = the MATCHER parameter. > The matcher is constructed by org-make-tags-matcher, so we know = everything it does -- > it does not move around and only asks about the current entry's tags = and properties. > org-scan-tags only invokes the matcher at the current entry, and sets = org-scanner-tags > correctly for that call. >=20 > But, you're right that there is a problem: while org-scan-tags sets = org-scanner-tags correctly > before (eval matcher), other users of the matcher -- e.g. = org-clock-get-table-data -- might not. > So, org-trust-scanner-tags should be set not in the matcher, but in = the function that calls > the matcher. A corrected patch is attached. >=20 > thanks, >=20 > ilya >=20 >=20 > On Thu, Mar 15, 2012 at 11:13 PM, Nick Dokos = wrote: > Ilya Shlyakhter wrote: >=20 >> The attached patch speeds up tags matching ( 50s --> 5s for my most >> common search ), by turning on org-trust-scanner-tags within the >> matcher. >>=20 >> (When it's off, getting a non-inherited property's value causes a = call >> to org-entry-properties to fetch all properties into a cache, >> including ALLTAGS; fetching ALLTAGS involves calling >> (org-get-tags-at), which is slow when org-trust-scanner-tags is off.) >>=20 >> Can this cause problems / was this off for a reason? >>=20 >=20 > I haven't looked at your patch carefully enough to know if it will or > will not cause problems, but check the doc for org-map-entries: it has > some guidelines about where the technique can be used and where it > cannot: >=20 > ,---- > | If your function needs to retrieve the tags including inherited tags > | at the *current* entry, you can use the value of the variable > | `org-scanner-tags' which will be much faster than getting the value > | with `org-get-tags-at'. If your function gets properties with > | `org-entry-properties' at the *current* entry, bind = `org-trust-scanner-tags' > | to t around the call to `org-entry-properties' to get the same = speedup. > | Note that if your function moves around to retrieve tags and = properties at > | a *different* entry, you cannot use these techniques. > `---- >=20 >=20 > There are warnings that this variable is for internal dynamical = scoping only, > so I suspect you should not mess with the default. If your search can = make > the needed guarantees, then you can just wrap it in a let to get the = speedup. > Otherwise, it probably should be left alone. >=20 > Nick >=20 >=20 >=20 > <0003-Clocking-work-time-faster-filtering-of-clock-entries.patch>