From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: 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/)] Date: Thu, 9 Jan 2020 09:45:28 +0100 Message-ID: References: <87v9sr7qpn.fsf@delllaptop.lockywolf.net> <87o8yjbc9g.fsf@nicolasgoaziou.fr> <87v9sp9ejl.fsf@nicolasgoaziou.fr> <87y2ujr198.fsf@nicolasgoaziou.fr> <871rs9g8w1.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000009798bb059bb108ff" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52968) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipTRo-0000Wt-UN for emacs-orgmode@gnu.org; Thu, 09 Jan 2020 03:45:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipTRn-0007O3-4a for emacs-orgmode@gnu.org; Thu, 09 Jan 2020 03:45:44 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:42970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipTRl-0007J6-K4 for emacs-orgmode@gnu.org; Thu, 09 Jan 2020 03:45:42 -0500 Received: by mail-wr1-x42b.google.com with SMTP id q6so6395465wro.9 for ; Thu, 09 Jan 2020 00:45:40 -0800 (PST) In-Reply-To: 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: Vladimir Nikishkin Cc: Org-mode --0000000000009798bb059bb108ff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =E6=96=BC 2020=E5=B9=B41=E6=9C= =889=E6=97=A5 =E9=80=B1=E5=9B=9B 01:23 =E5=AF=AB=E9=81=93=EF=BC=9A > >> 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) (=3D (remainder b a) 0)) >> >> (define (prime? n) >> (=3D n (smallest-divisor n))) >> #+end_src >> >> >> Regards, >> >> -- >> Nicolas Goaziou >> > --0000000000009798bb059bb108ff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Vladimir,

The main difference I have= noticed is that you can have multiple blocks with the same :noweb-ref head= er 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 s= omewhere 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 :no= web-ref tangling is slow, since all blocks need to be scanned and put toget= her.

--Diego


On Thu, Jan 9, 20= 20 at 2:43 AM Vladimir Nikishkin <lockywolf@gmail.com> wrote:
Ouch, that was unexpected.

The manual for my version only incl= udes four mentions if the noweb-ref header argument. Is it becoming depreca= ted?

What does "app= arently 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 th= e name cannot?


Nicolas Goaziou <mail@nicolasgoaziou.fr> =E6=96=BC 2020=E5=B9= =B41=E6=9C=889=E6=97=A5 =E9=80=B1=E5=9B=9B 01:23 =E5=AF=AB=E9=81=93=EF=BC= =9A
Hello,

Vladimir Nikishkin <lockywolf@gmail.com> 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 reaso= n
> 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<= br> apparently don't need it in the document. Use name keyword instead,
e.g.,

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

=C2=A0 =C2=A0 =C2=A0 (define (prime? n)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (=3D n (smallest-divisor n)))
=C2=A0 =C2=A0 #+end_src


Regards,

--
Nicolas Goaziou
--0000000000009798bb059bb108ff--