help-octave
[Top][All Lists]
Advanced

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

Re: octave loop slowness (was "")


From: Bill Denney
Subject: Re: octave loop slowness (was "")
Date: Mon, 20 Mar 2006 21:19:28 -0500 (EST)

If you could write such a document, the wiki or the website would be interested in it. I know that I learned something about the JIT compiler in the past two messages, and I would guess that many other people did, too. Having it documented more fully would definitely be helpful.

Bill

On Mon, 20 Mar 2006, Brendan Drew wrote:

Doing the JIT "properly" gets to be a mess, because you end up having to basically throw away your entire interpreter and writing a full-up compiler which translates Matlab-ish code --> JVM microcode. I can understand why Mathworks didn't want to go this way --- you end up throwing away the entire interpreter in favor of relying entirely on the JVM. A nasty side effect of this is that you end up completely breaking your previous language bindings (i.e. all the mex files won't work anymore) because you have to write to Java's language bindings (the only other option is an unspeakably nasty kludge). So, instead, Mathworks opted to compromise and use the JIT where it was easy to do without breaking things. I can't say I blame them for this decision.

Writing fast tight loops in /any/ interpreted language is going to be really hard unless you are excessively smart in how you design the loop interpreting code. Unfortunately, you've got to either a) suck up the fact that loops (barring special cases) are going to be slow or b) suck up the fact fast loops need to be done in C/C++. The good news is that there isn't typically much code that needs to be done in C++ to see significant speed ups. For example, I did histogram code in C++ for image processing, which ended up cutting the run time of my code by an order of magnitude. I wrote a simple wrapper for libpng to do very basic image I/O and I ended up with another factor of 2 speed up. Very little of the original octave code was modified, yet I managed to speed things up nearly 20 fold.

Would it be useful to produce a document explaining some of these issues (perhaps together with some case studies showing different strategies for speeding code up)?

Paul Billings wrote:
Many people compare octave to Matlab and don't realize that Matlab has
invested mucho $$ in the JIT (just-in-time or "on the fly" compiling).
While people are quick to say, "Matlab's JIT is great, why doesn't octave
have one?", I personally don't think the JIT buys you much at all.  The
primary flaw in Matlab's JIT is that you cannot call any user functions
within the loop!

Must structured programming is, well, structured, and has numerous calls to
functions which call functions, etc.  For a sequence of calls to built-in
functions, I will encapsulate this into a user function so that it is
readable in the calling code and maintainable.  Whoops, I've just defeated
Matlab's fancy JIT, but I live with it since scattered cut-and-pasted code
blocks are unacceptable to me.

To put it another way: I can pretend that octave has a JIT.  For my code,
the "octave JIT" is about as effective as Matlab's -- meaning, it ain't.  I
am happy that the people guiding this project understand that other features
are of greater use.

Paul


-----Original Message-----
From: John W. Eaton [mailto:address@hidden
Sent: Saturday, March 18, 2006 4:41 AM
To: Jordi Gutierrez Hermoso
Cc: address@hidden
Subject: Re: octave loop slowness (was "")


On 17-Mar-2006, Jordi Gutierrez Hermoso wrote:

| Of all the complaints I have heard about Octave, its slowness is the
| one that stings the most painfully. Cuts deep. Real deep.
|
| So, I'm interested to know, any idea why this is happening? Why would
| a simple for loop with no code to execute except running through all
| the values of its iterator take orders of magnitude more in Octave
| than in Matlab?

I can think of a few possibilities:

  * because Octave's author only knows how to write a naive
    interpreter and is too busy with other tasks to spend a lot of
    time improving the interpreter (do you have a better one?)

  * no interpreter/compiler wizards have appeared on the scene with
    anything better

  * people who have paid actual money for Octave's development have
    cared more about features, correct results, and the fact that
    Octave is freely available than speed (which has apparently been
    good enough for them)

  * our army of programmers is damn small and underfunded

Now, what can you do about it?  Would you like to help, or just
complain?

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




--
Brendan Drew
Research Scientist
PercepTek, Inc.
12395 North Mead Way
Littleton, CO 80125
Tel: 720-344-1037 x 126
Fax: 720-344-2360



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------


--
"Some people don't like an audience when they work.  Enough of them have
told me so with blunt instruments that I'm a phrenologist's dream come
true."
  -- Calvin, 10/26/1991



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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