Re: Bug: org-babel-expand-noweb-references is very slow [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)]

2020-01-09 Thread Diego Zamboni
Hi Vladimir,

The main difference I have noticed is that you can have multiple blocks
with the same :noweb-ref header argument, and they will be concatenated on
tangle. I use this in some of my files to progressively build a block of
code which is then referenced somewhere else. With #+name, you can have
only one block with each name, the others are discarded (can't remember if
it's the first or the last one that gets used).

I guess this is also why :noweb-ref tangling is slow, since all blocks need
to be scanned and put together.

--Diego


On Thu, Jan 9, 2020 at 2:43 AM Vladimir Nikishkin 
wrote:

> Ouch, that was unexpected.
>
> The manual for my version only includes four mentions if the noweb-ref
> header argument. Is it becoming deprecated?
>
> What does "apparently don't need" actually mean? That is, when should I
> use the name, and when the header argument? What can the header argument do
> that the name cannot?
>
>
> Nicolas Goaziou  於 2020年1月9日 週四 01:23 寫道:
>
>> Hello,
>>
>> Vladimir Nikishkin  writes:
>>
>> > I am attaching the file in which tangling is still slow.
>> >
>> > The file is quite big, but that alone doesn't seem to be the reason
>> > for slowliness (I tried adding 1M-long words in the random places of
>> > the previous mwe).
>> >
>> > You can see the result by C-c C-v C-v'ing the code block at the
>> > "Ramanujan numbers" heading.
>> >
>> > Below is the profiler report for C-c C-v C-v'ing.with the heaviest
>> > blocks expanded:
>>
>> This is because you're using :noweb-ref, which _is_ slow, although you
>> apparently don't need it in the document. Use name keyword instead,
>> e.g.,
>>
>> #+name: primetest
>> #+begin_src scheme :exports both :results output
>>   (define (smallest-divisor n)
>> (find-divisor n 2))
>>   (define (find-divisor n test-divisor)
>> (cond ((> (square test-divisor) n) n)
>>   ((divides? test-divisor n) test-divisor)
>>   (else (find-divisor n (+ test-divisor 1)
>>   (define (divides? a b) (= (remainder b a) 0))
>>
>>   (define (prime? n)
>> (= n (smallest-divisor n)))
>> #+end_src
>>
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou
>>
>


Re: Bug: org-babel-expand-noweb-references is very slow [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)]

2020-01-08 Thread Vladimir Nikishkin
Ouch, that was unexpected.

The manual for my version only includes four mentions if the noweb-ref
header argument. Is it becoming deprecated?

What does "apparently don't need" actually mean? That is, when should I use
the name, and when the header argument? What can the header argument do
that the name cannot?


Nicolas Goaziou  於 2020年1月9日 週四 01:23 寫道:

> Hello,
>
> Vladimir Nikishkin  writes:
>
> > I am attaching the file in which tangling is still slow.
> >
> > The file is quite big, but that alone doesn't seem to be the reason
> > for slowliness (I tried adding 1M-long words in the random places of
> > the previous mwe).
> >
> > You can see the result by C-c C-v C-v'ing the code block at the
> > "Ramanujan numbers" heading.
> >
> > Below is the profiler report for C-c C-v C-v'ing.with the heaviest
> > blocks expanded:
>
> This is because you're using :noweb-ref, which _is_ slow, although you
> apparently don't need it in the document. Use name keyword instead,
> e.g.,
>
> #+name: primetest
> #+begin_src scheme :exports both :results output
>   (define (smallest-divisor n)
> (find-divisor n 2))
>   (define (find-divisor n test-divisor)
> (cond ((> (square test-divisor) n) n)
>   ((divides? test-divisor n) test-divisor)
>   (else (find-divisor n (+ test-divisor 1)
>   (define (divides? a b) (= (remainder b a) 0))
>
>   (define (prime? n)
> (= n (smallest-divisor n)))
> #+end_src
>
>
> Regards,
>
> --
> Nicolas Goaziou
>


Re: Bug: org-babel-expand-noweb-references is very slow [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)]

2020-01-08 Thread Nicolas Goaziou
Hello,

Vladimir Nikishkin  writes:

> I am attaching the file in which tangling is still slow.
>
> The file is quite big, but that alone doesn't seem to be the reason
> for slowliness (I tried adding 1M-long words in the random places of
> the previous mwe).
>
> You can see the result by C-c C-v C-v'ing the code block at the
> "Ramanujan numbers" heading.
>
> Below is the profiler report for C-c C-v C-v'ing.with the heaviest
> blocks expanded:

This is because you're using :noweb-ref, which _is_ slow, although you
apparently don't need it in the document. Use name keyword instead,
e.g.,

#+name: primetest
#+begin_src scheme :exports both :results output
  (define (smallest-divisor n)
(find-divisor n 2))
  (define (find-divisor n test-divisor)
(cond ((> (square test-divisor) n) n)
  ((divides? test-divisor n) test-divisor)
  (else (find-divisor n (+ test-divisor 1)
  (define (divides? a b) (= (remainder b a) 0))

  (define (prime? n)
(= n (smallest-divisor n)))
#+end_src


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: org-babel-expand-noweb-references is very slow [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)]

2019-10-14 Thread Nicolas Goaziou
Hello,

Vladimir Nikishkin  writes:

> The mwe would be like:
>
> #+begin_src scheme :exports both :results output :noweb-ref bug1
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug2
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug3
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug4
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug5
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug6
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug7
> #+end_src
>
> #+begin_src scheme :exports both :results output :noweb-ref bug8
> #+end_src
>
> #+begin_src scheme :exports both :results output
> <>
> <>
> <>
> <>
> <>
> <>
> <>
> <>
> #+end_src
>
> C-c C-v C-v is already very slow, takes ~15 seconds to resolve the references
> (can be seen in the Emacs Profiler), even though the inclusion graph is
> very simple.

Please try a more recent version of Org. Release 9.1.9 is pretty old. It
might be fixed already.

Regards,

-- 
Nicolas Goaziou



[O] Bug: org-babel-expand-noweb-references is very slow [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)]

2019-10-14 Thread Vladimir Nikishkin



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Hello, everyone.

The mwe would be like:

#+begin_src scheme :exports both :results output :noweb-ref bug1
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug2
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug3
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug4
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug5
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug6
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug7
#+end_src
#+begin_src scheme :exports both :results output :noweb-ref bug8
#+end_src
#+begin_src scheme :exports both :results output
<>
<>
<>
<>
<>
<>
<>
<>
#+end_src

C-c C-v C-v is already very slow, takes ~15 seconds to resolve the references
(can be seen in the Emacs Profiler), even though the inclusion graph is
very simple.

Emacs  : GNU Emacs 26.3 (build 1, x86_64-slackware-linux-gnu, GTK+ Version 
3.24.10)
 of 2019-08-30
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/share/emacs/26.3/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-babel-after-execute-hook '((lambda nil
 (if org-inline-image-overlays
  (progn (org-redisplay-inline-images)))
 )
)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-pretty-entities t
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-agenda-files '("~/DevLinux/chibi-sicp/index.org" 
"~/Personal_Planner/Planner.org")
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-modules '(org-habits org-w3m org-bbdb org-bibtex org-docview org-gnus 
org-info org-irc
   org-mhe org-rmail)
 org-plantuml-jar-path "/usr/local/bin/plantuml.jar"
 org-mode-hook '(turn-on-org-cdlatex (lambda nil (imenu-add-to-menubar "Imenu"))
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-block-all append 
local] 5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all 
append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-latex-compiler "lualatex"
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((plantuml . t) (C . t) (scheme . t) (latex . t))
 org-log-done 'time
 org-startup-align-all-tables t
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-catch-invisible-edits t
 org-occur-hook '(org-first-headline-recenter)
 org-edit-src-auto-save-idle-delay 15
 org-agenda-include-diary t
 org-structure-template-alist '(("E"
 "#+begin_src elisp :exports both :results 
output\n?\n#+end_src")
("SV"
 "#+begin_src scheme :exports both :results 
value\n?\n#+end_src")
("SO"
 "#+begin_src scheme :exports both :results 
output\n?\n#+end_src")
("p"
 "#+begin_src plantuml :exports both :file ? 
\n#+end_src ")
("s" "#+BEGIN_SRC ?\n\n#+END_SRC")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE")
("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE")
("v" "#+BEGIN_VERSE\n?\n#+END_VERSE")
("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM")
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER")
("C" "#+BEGIN_COMMENT\n?\n#+END_COMMENT")
("l" "#+BEGIN_EXPORT lat