emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] speeding up Babel Gnuplot


From: Thierry Banel
Subject: Re: [O] speeding up Babel Gnuplot
Date: Wed, 04 Jan 2017 21:29:19 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]