From: Thierry Banel <tbanelwebmin@free.fr>
To: emacs-orgmode@gnu.org
Subject: Re: speeding up Babel Gnuplot
Date: Wed, 04 Jan 2017 21:29:19 +0100 [thread overview]
Message-ID: <586D5B1F.2040803@free.fr> (raw)
In-Reply-To: <87tw9eg28w.fsf@Rainer.invalid>
Le 04/01/2017 18:32, Achim Gratz a écrit :
> Thierry Banel writes:
>> There is no way to ensure a single call to
>> (org-babel-gnuplot-process-vars) without modifying ob-core.el. I don't
>> want to do that because I would have to change a lot of babel backends.
> But that is the right fix to apply, unless there is a reason for the
> input vars to be processed multiple times. I haven't looked at the
> Babel code in the last two years, but generally I'd suggest that each
> argument should only be processed once per Babel block since the second
> processing could have unwanted side-effects.
>
>
Absolutely! But not so easy.
Here is a simplified version of the involved functions:
#+BEGIN_SRC elisp
(defun org-babel-expand-body:gnuplot (body params)
(let ((vars (org-babel-gnuplot-process-vars params))) ;; <-- 1st call
(org-babel-variable-assignments:gnuplot params)))
(defun org-babel-variable-assignments:gnuplot (params)
(org-babel-gnuplot-process-vars params)) ;; <-- 2nd call
(defun org-babel-gnuplot-process-vars (params)
(... generate temp file ...))
#+END_SRC
Following the flow of calls, we can see that starting from
(org-babel-expand-body:gnuplot), the function
(org-babel-gnuplot-process-vars) is called twice.
I would like to pass `vars' around (which is the result of the first
call) to avoid the second call. To do that I need to add a parameter
`vars' to (org-babel-variable-assignments:gnuplot). Unfortunately I
cannot because the parameter of this function (and all functions
matching (org-babel-variable-assignments:*)) is enforced by the Babel core.
Therefore to pass information around, the only channel is the `params'
parameter. I use it as a cache in my patch.
Moreover, the above simplified ELisp sketch is not the whole story.
There is also the (org-babel-prep-session:gnuplot) function involved. I
have not yet investigated that. But, the `params' cache trick takes care
of this flow without having to understand it.
To sum-up: yes, ob-gnuplot.el is doing the double `params' processing.
But to avoid that without the cache trick, ob-core.el should be changed,
as well as all dependent ob-*.el backends. Lot of work. Or I may be
missing something...
Regards
Thierry
next prev parent reply other threads:[~2017-01-04 20:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 20:33 speeding up Babel Gnuplot Thierry Banel
2016-12-29 20:04 ` Nicolas Goaziou
2016-12-29 20:34 ` Thierry Banel
2017-01-01 20:17 ` Thierry Banel
2017-01-01 23:34 ` Nicolas Goaziou
2017-01-02 20:11 ` Thierry Banel
2017-01-03 21:40 ` Thierry Banel
2017-01-03 21:55 ` Nicolas Goaziou
2017-01-03 23:06 ` Thierry Banel
2017-01-04 22:36 ` Nicolas Goaziou
2017-01-05 20:47 ` Thierry Banel
2017-01-06 9:41 ` Nicolas Goaziou
2017-01-06 18:24 ` Thierry Banel
2017-01-04 17:32 ` Achim Gratz
2017-01-04 20:29 ` Thierry Banel [this message]
2017-01-04 23:15 ` Charles C. Berry
2017-01-05 20:23 ` Thierry Banel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=586D5B1F.2040803@free.fr \
--to=tbanelwebmin@free.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).