all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Cc: nicholas.dokos@hp.com
Subject: Re: [PATCH] tags search: faster tags matcher by trusting scanner tags
Date: Fri, 16 Mar 2012 00:31:13 -0400	[thread overview]
Message-ID: <CACfYvRZ+VgR16kzZoO+qr2FC3XE8prPnLFfEnS-6N+QafHXHLA@mail.gmail.com> (raw)
In-Reply-To: <3953.1331867583@alphaville>


[-- Attachment #1.1: Type: text/plain, Size: 2573 bytes --]

,----
| If your function needs to retrieve the tags including inherited tags
| at the *current* entry,

'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.

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.

thanks,

ilya

On Thu, Mar 15, 2012 at 11:13 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:

> Ilya Shlyakhter <ilya_shl@alum.mit.edu> wrote:
>
> > The attached patch speeds up tags matching ( 50s --> 5s for my most
> > common search ), by turning on org-trust-scanner-tags within the
> > matcher.
> >
> > (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.)
> >
> > Can this cause problems / was this off for a reason?
> >
>
> 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:
>
> ,----
> | 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.
> `----
>
>
> 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.
>
> Nick
>
>

[-- Attachment #1.2: Type: text/html, Size: 3217 bytes --]

[-- Attachment #2: 0002-Tags-properties-matcher-faster-matching-by-trusting-.patch --]
[-- Type: application/octet-stream, Size: 1043 bytes --]

From 95c38b06803aec0787bc2eaab3d0062221390292 Mon Sep 17 00:00:00 2001
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
Date: Fri, 16 Mar 2012 00:10:25 -0400
Subject: [PATCH 2/2] Tags/properties matcher: faster matching by trusting
 org-scanner-tags

* lisp/org.el (org-scan-tags): Bind org-trust-scanner-tags to t
while evaluating the matcher, since the matcher is always evaluated
at the current entry.

TINYCHANGE
---
 lisp/org.el |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index ad63213..951f692 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12906,7 +12906,8 @@ headlines matching this string."
 
 		 ;; eval matcher only when the todo condition is OK
 		 (and (or (not todo-only) (member todo org-not-done-keywords))
-		      (let ((case-fold-search t)) (eval matcher)))
+		      (let ((case-fold-search t) (org-trust-scanner-tags t))
+			   (eval matcher)))
 
 		 ;; Call the skipper, but return t if it does not skip,
 		 ;; so that the `and' form continues evaluating
-- 
1.7.9.3


  reply	other threads:[~2012-03-16  4:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 23:16 [PATCH] tags search: faster tags matcher by trusting scanner tags Ilya Shlyakhter
2012-03-16  3:13 ` Nick Dokos
2012-03-16  4:31   ` Ilya Shlyakhter [this message]
2012-03-16  4:34     ` Ilya Shlyakhter
2012-03-16 10:35       ` Carsten Dominik
2012-03-16 14:25         ` Nick Dokos
2012-03-16  6:10     ` Nick Dokos
2012-03-16 14:13       ` Ilya Shlyakhter
2012-03-16 16:31         ` Carsten Dominik
2012-03-16 14:20       ` Ilya Shlyakhter
2012-03-16 16:35         ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACfYvRZ+VgR16kzZoO+qr2FC3XE8prPnLFfEnS-6N+QafHXHLA@mail.gmail.com \
    --to=ilya_shl@alum.mit.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.