emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Fwd: slow capture templates
Date: Thu, 22 May 2014 18:34:24 -0400	[thread overview]
Message-ID: <87mwe9cvug.fsf@alphaville.bos.redhat.com> (raw)
In-Reply-To: CAOa+0osZ5LYUMY1+01SEcfr6kPOSz70vnt==aJ2wMSnm6PtONw@mail.gmail.com

jamil egdemir <unclejamil@gmail.com> writes:

> Using M-x org-version RET I get:
> Org-mode version 8.2.6 (release_8.2.6-1 @
> /home/jegdemir/share/emacs/24.4.50/lisp/org/)
>

...and which OS and which X are you using?

> In an attempt to follow you suggestion,  I fired up a few calls to
> x-get-selection in my *scratch* but didn't find anything exciting:
> ...
>
> I was hoping this would expose something since the two function calls
> in org-eventually boil down to x-get-selection (I think) but no dice.
> I also tried 'STRING and 'TEXT as arguments in the x-get-selection...
> results were the same and execution time was snappy.

So calling it by hand is fast, but calling it through org-capture is
extremely slow. Can you run an instrumented x-get-selection by hand and
see *how* fast the fast case is? On my system, I get 2.8ms per call, so
the ratio between that and your slow x-get-selection (admittedly a
meaningless number but that's why I wanted your fast value) is 150 or
so. I tried to come up with a theory here, but I must admit I'm baffled.

> ...
> x-get-selection                                               24
>    115.30194600  4.8042477502
> x-get-selection-internal                                      24
>    115.30104917  4.8042103823
> ...
> Looking at the definitions of the capture templates I'm using I'm not
> sure if I understand why the call is being made in the first place if
> the capture template does not contain %x.  Not that I think this would
> solve my deeper problem but it does seem like a good idea to check the
> template before pulling the clipboard contents as a matter of course.
>

That's probably true, but they *are* supposed to be fairly fast calls,
so a little inefficiency might not be too important. Besides, you
wouldn't have known that you have a problem with X selections if org
were more efficient :-)

> In any case it seems unintentional to me that using a capture template
> should induce 6 calls to org-get-x-clipboard and 24 calls to
> x-get-selection.
>

org-capture-fill-template can call org-get-x-clipboard from 4 to 6 times
and org-get-x-clipboard can call x-get-selection from 1 to 4 times, so
x-get-selection can be called from 4 to 24 times in each capture - you
got the worst-case scenario: 24 is the maximum. In my case, I had 4
calls to org-get-x-clipboard and 11 calls to x-get-selection. And at 3ms
per call, even 24 calls is probably insignificant - but not at 5s a call!

Nick

  reply	other threads:[~2014-05-22 22:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22  7:07 slow capture templates jamil egdemir
2014-05-22  8:49 ` Bastien
2014-05-22 15:51   ` jamil egdemir
2014-05-22 16:34     ` Bastien
2014-05-22 21:25       ` Fwd: " jamil egdemir
2014-05-22 22:34         ` Nick Dokos [this message]
2014-05-23  5:35           ` Bastien
2014-05-23  6:07             ` Nick Dokos

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87mwe9cvug.fsf@alphaville.bos.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).