Re: [O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-09 Thread Nicolas Goaziou
Hello,

Karl Voit  writes:

> IMHO, the profiler reports showed a common pattern: a reasonable
> amount of CPU got into line-number-at-pos if I read the profiler
> report correctly. (see below)

Does the following patch improve the situation?


Regards,

-- 
Nicolas Goaziou
>From 54b8e7466d4689be3c34f7041244563771e2178a Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou 
Date: Thu, 9 Jan 2014 20:36:23 +0100
Subject: [PATCH] ob-core: Speed improvement

* lisp/ob-core.el (org-babel-get-inline-src-block-matches): Do not
  compute line number if all is needed is to know if we're on the
  first one.
---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f06cdaf..e8943c6 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -217,7 +217,7 @@ Returns non-nil if match-data set"
   (let ((src-at-0-p (save-excursion
 		  (beginning-of-line 1)
 		  (string= "src" (thing-at-point 'word
-	(first-line-p (= 1 (line-number-at-pos)))
+	(first-line-p (= (line-beginning-position) (point-min)))
 	(orig (point)))
 (let ((search-for (cond ((and src-at-0-p first-line-p  "src_"))
 			(first-line-p "[[:punct:] \t]src_")
-- 
1.8.5.2



Re: [O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-09 Thread Karl Voit
* Bastien  wrote:
> Karl Voit  writes:
>
>> I guess that with Emacs prelude, I got some functionality which is
>> causing these issues. So this might be of interest of other
>> Emacs/prelude users as well.
>
> Yes, probably, since the Org version is the same :)
> Better ping the Emacs prelude devs directly IMHO.

Today, I did another test. I converted my config to Emacs24 with the
most current Org-mode from git and without prelude at all.

Unfortunately, the performance issue stayed :-(

IMHO, the profiler reports showed a common pattern: a reasonable
amount of CPU got into line-number-at-pos if I read the profiler
report correctly. (see below)

I also turned off all visible minor modes from the mode line. No
change.

Since prelude is out of this game, what can I check to find the
source of this poor performance?


profiler report (CPU) of ~M-~ of a simple list item without prelude:
#+BEGIN_EXAMPLE
- command-execute1280  98%
 - call-interactively1280  98%
  - org-metadown 1004  77%
   - run-hook-with-args-until-success1004  77%
- org-babel-pop-to-session-maybe 1004  77%
 - org-babel-get-inline-src-block-matches1000  76%
line-number-at-pos   1000  76%
  - byte-code 265  20%
   - read-extended-command265  20%
- completing-read 265  20%
 - completing-read-default265  20%
  - read-from-minibuffer  253  19%
   + command-execute   43   3%
   + redisplay_internal (C function)3   0%
  + execute-extended-command   11   0%
+ ...  15   1%
+ redisplay_internal (C function)   4   0%
#+END_EXAMPLE

profiler-report (CPU) of ~C-c C-c~ in a simple table without prelude:
#+BEGIN_EXAMPLE
 command-execute   17492  94%
 - call-interactively   17492  94%
  - org-ctrl-c-ctrl-c   16137  86%
   - org-table-align 5844  31%
+ org-indent-refresh-maybe  8   0%
  org-table-goto-column 4   0%
   - run-hook-with-args-until-success4469  24%
- org-babel-execute-safely-maybe 4469  24%
 - org-babel-execute-maybe   4469  24%
  - org-babel-execute-src-block-maybe4469  24%
   - org-babel-get-inline-src-block-matches  4449  23%
  line-number-at-pos 4449  23%
 org-babel-where-is-src-block-head 16   0%
  + byte-code1311   7%
  + minibuffer-complete33   0%
  + execute-extended-command7   0%
+ timer-event-handler1076   5%
+ ...  24   0%
+ redisplay_internal (C function)  14   0%
#+END_EXAMPLE

profiler-report (CPU) of ~M-~ of a heading containing
approx. 2 lines of appointments and notes without prelude:
#+BEGIN_EXAMPLE
- command-execute  123676  83%
 - call-interactively  123676  83%
  - org-metaup 115952  77%
   - call-interactively 87337  58%
- org-move-subtree-up   87337  58%
 - org-move-subtree-down87225  58%
  - insert-before-markers   86598  58%
   - org-indent-refresh-maybe   86594  58%
- org-indent-add-properties 82086  55%
 - org-at-item-p72884  48%
  - org-list-in-valid-context-p 69497  46%
   - org-in-block-p 69493  46%
- byte-code 69421  46%
 - mapc 63094  42%
  - #63022  42%
   - org-between-rege

Re: [O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-09 Thread Eric S Fraga
Hi,

Just to add that I have experienced some severe performance hits in a
recent snapshot, particularly noticeable when yanking from the X
clipboard.  I haven't tracked it down yet nor looked on the emacs dev
groups and lists.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.1, Org release_8.2.4-322-gece429




Re: [O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-07 Thread Karl Voit
* Bastien  wrote:
> Karl Voit  writes:
>
>> I guess that with Emacs prelude, I got some functionality which is
>> causing these issues. So this might be of interest of other
>> Emacs/prelude users as well.
>
> Yes, probably, since the Org version is the same :)
> Better ping the Emacs prelude devs directly IMHO.

OK, I'll file a bug on GitHub. Thanks!

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github




Re: [O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-07 Thread Bastien
Karl Voit  writes:

> I guess that with Emacs prelude, I got some functionality which is
> causing these issues. So this might be of interest of other
> Emacs/prelude users as well.

Yes, probably, since the Org version is the same :)
Better ping the Emacs prelude devs directly IMHO.

-- 
 Bastien



[O] Performance issues after upgrading from Emacs 23.3 to 24.3+prelude

2014-01-06 Thread Karl Voit
Hi!

I have got very severe performance issues after I upgraded my Emacs.

Before upgrading:
- Debian stable x64
- Emacs 23.3 (Debian stable deb-package)
- Org-mode from git: version 8.2.3c (release_8.2.3c-225-g668ba5)
- no prelude

Now:
- Debian stable x64
  - no change but I replaced Debian Emacs packages with
Emacs-snapshot and MELPA/Marmelade
- Emacs-snapshot 24.3.50.1 from [1]
- Org-mode from git: version 8.2.3c (release_8.2.3c-225-g668ba5)
  - no change
- Emacs prelude from [2]


I mainly use Emacs for Org-mode and therefore I got issues only in
Org-mode. Some tasks are very slow and take 100% of a CPU core. This
is the rare occasion where I am happy that Emacs is single-threaded
:-)

Further down, there are three examples with their profiling results.
I don't know how to interpret the profiling results properly. 


Most annoying: sometimes, Emacs starts using up its CPU core at 100%
without any particular reason or event I am aware of. Probably it is
while auto-saving (not every time!) but I am not sure. 

I have no idea on how to debug this behavior because when Emacs is
blocking completely, it is not even updating its buffer display nor
reacting on C-g or similar. However, I am able to kill (with default
kill signal) the Emacs process without leaving unsaved buffers.


I guess that with Emacs prelude, I got some functionality which is
causing these issues. So this might be of interest of other
Emacs/prelude users as well.


* Example 1: moving an item in a list up/down

I just switch two lines of a simple list by invoking M-:
- foo
- bar
- baz (is moved one line up)

This took only a fraction of a second before. Now I ave to wait
approx. 2-3 seconds.

I learned how to use the Emacs profiler and generated a CPU-report
when invoking the command: [3]

Interestingly, when I am using M-x org-move-item-up, it does not
show the slow-down effect.


* Example 2: M- on a heading containing 2 lines of
appointments and notes

This task took almost two minutes. Before the update, this was
probably done in a couple of seconds.

Here is the CPU-report of the profiler: [4]


* Example 3: Re-calculating and formatting of a 10x10 table

The table has 10x10 cells and four very simple formulas. The
operation took approx. 1-3s before the update. Now, it takes over
four minutes.

The command invoked was: C-u C-u C-c C-c

CPU-profiling report: [5]


  1. http://emacs.naquadah.org/
  2. git://github.com/bbatsov/prelude.git
  3. http://pastebin.com/mQRDYbq7 -> M- on a list item
  4. http://pastebin.com/P2sJPsHy -> moving large heading
  5. http://pastebin.com/3Kw6knYU -> re-calculating table
-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github