From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: finding close tasks has infinite loop [9.0.5 (release_9.0.5-433-ge65be5 @ /home/hs/.emacs.d/git/org-mode/lisp/)] Date: Tue, 25 Apr 2017 23:57:04 +0200 Message-ID: <87d1c06thr.fsf@nicolasgoaziou.fr> References: <20170407073930.GA7217@seven> <20170412124435.GC14068@seven> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d38SJ-0004et-Pw for emacs-orgmode@gnu.org; Tue, 25 Apr 2017 17:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d38SI-00014M-SQ for emacs-orgmode@gnu.org; Tue, 25 Apr 2017 17:57:07 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:48682) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d38SI-00013g-LV for emacs-orgmode@gnu.org; Tue, 25 Apr 2017 17:57:06 -0400 In-Reply-To: <20170412124435.GC14068@seven> (Stefan-W. Hahn's message of "Wed, 12 Apr 2017 14:44:35 +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" To: "Stefan-W. Hahn" Cc: emacs-orgmode@gnu.org Hello, "Stefan-W. Hahn" writes: > Mail von Stefan-W. Hahn, Fri, 07 Apr 2017 at 09:39:30 +0200: > > Hello, > > I tried an instrumented version with code below and got an hint where the > time get consumed. > >> #+BEGIN_QUOTE >> ** DONE Task :@status: >> CLOSED: [2017-02-17 Fr 14:08] >> :CLOCK: >> CLOCK: [2016-03-07 Mo 12:58]--[2016-03-07 Mo 14:09] => 1:11 > > 979 CLOCK lines, gives 1958 org-time entries. > >> CLOCK: [2011-09-26 Mo 13:02]--[2011-09-26 Mo 13:48] => 0:46 >> :END: >> Added: [2011-09-26 Mo] >> >> #+END_QUOTE >> > > With following code I let it run. It came to an end after 119 seconds: > > #+BEGIN_SRC emacs-lisp > > (defmacro profile-org (times &rest body) > `(let (output) > (dolist (p '("org-")) ; symbol prefixes to instrument > (elp-instrument-package p)) > (dotimes (x ,times) > ,@body) > (elp-results) > (elp-restore-all) > (point-min) > (forward-line 20) > (delete-region (point) (point-max)) > (setq output (buffer-substring-no-properties (point-min) (point-max))) > (kill-buffer) > (delete-window) > output)) > > (let ((org-agenda-files > '("~/notes/bug/test.org"))) > (profile-org 1 > (org-tags-view nil "+CLOSED<=\"<-1m>\""))) > #+END_SRC > > > This is the elp-result: > > #+BEGIN_QUOTE > > Back to top level > org-tags-view 1 119.90470040 119.90470040 > org-scan-tags 1 119.89504432 119.89504432 > org-entry-properties 2 119.89459378 59.947296892 > org-cached-entry-get 1 119.89455419 119.89455419 > org-element-context 1959 119.88264565 0.0611958374 > org-element-at-point 1959 119.87516006 0.0611920163 > org-element--parse-to 1959 119.61624070 0.0610598472 > org-element--current-element 963339 106.53174518 0.0001105859 > org-element-clock-parser 959420 77.279206300 8.054...e-05 > org-element-timestamp-parser 961380 60.700601205 6.313...e-05 > org-parse-time-string 1920801 32.491741821 1.691...e-05 > org-get-limited-outline-regexp 969216 10.924480618 1.127...e-05 > org-at-heading-p 967259 4.0055616979 4.141...e-06 > org-element--cache-put 963339 2.1260797540 2.206...e-06 > org-element-drawer-parser 1959 0.5903366010 0.0003013458 > org-element-planning-parser 1959 0.0443325489 2.263...e-05 > org-element--collect-affiliated-keywords 1960 0.0102636800 5.236...e-06 > org-agenda-prepare 1 0.008041049 0.008041049 > org-agenda-mode 1 0.002911944 0.002911944 > org-agenda-prepare-buffers 1 0.002577423 0.002577423 > > #+END_QUOTE > > It gives an amazing number of calles to org-parse-time-string, around 981 > calls or each org-timestamp. This is not that amazing. Each `org-element-clock-parser' calls `org-parse-time-string' twice. Anyway, this probably happens because parsing an element starts from the headline, so parsing multiple elements has a quadratic behaviour. You may want to try to activate the cache. See `org-element-use-cache' docstring, though. Regards, -- Nicolas Goaziou