From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Fwd: slow capture templates Date: Thu, 22 May 2014 18:34:24 -0400 Message-ID: <87mwe9cvug.fsf@alphaville.bos.redhat.com> References: <87wqde9p1b.fsf@bzg.ath.cx> <87k39dkc18.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnbZY-0002qO-Oc for emacs-orgmode@gnu.org; Thu, 22 May 2014 18:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnbZR-0000SC-8k for emacs-orgmode@gnu.org; Thu, 22 May 2014 18:34:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:44949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnbZR-0000Ry-19 for emacs-orgmode@gnu.org; Thu, 22 May 2014 18:34:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WnbZO-0003ka-Ls for emacs-orgmode@gnu.org; Fri, 23 May 2014 00:34:38 +0200 Received: from pool-98-110-160-12.bstnma.fios.verizon.net ([98.110.160.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 May 2014 00:34:38 +0200 Received: from ndokos by pool-98-110-160-12.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 May 2014 00:34:38 +0200 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: emacs-orgmode@gnu.org jamil egdemir 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