As far as I know GNU Octave interprets the code by evaluating the AST (which
is a slow method).
A better idea is to use a virtual machine (VM). By VM I mean something like
Java Virtual Machine (JVM). VMs are very popular among popular programming
I think the first step toward faster Octave is to have a VM.
My suggestion is to have a VM generated by GNU Jitter (Jitter - GNU Project - Free Software Foundation).
GNU Jitter is a software automatically generating a portable, very efficient
language virtual machine with performance close to native code, starting from
a relatively high-level specification provided by the user.
It can generates 4 kinds of VM implementation. From a portable switch dispatch,
to more sophisticated dispatches which behaves more like a JIT.
GNU poke (GNU poke) project uses jitter for its virtual
machine (Poke Virtual Machine (PVM)).
I’d like to implement the VM for Octave if there’s an interest in the community.
If you are interested I can prepare a presentation with more info for the next
Octave developers meeting to discuss this option.
Since VMs are a separate topic from JIT using libgccjit, could the VM comments (including this one) be moved to a separate topic pls? (@siko1056 I think you can do this? I don’t have that functionality.)
Re VMs, yes @mnabipoor please add your topic as an item here: Online Developer Meeting (2022-05-24) - Octave
The reason I talked about a Jitter-generated VM in this topic is that if Octave use Jitter to generate the VM, it no longer needs JIT support through
libgccjit. Jitter-generated VM (with advanced dispaches) can gives a very good performance.
Jitter achieves high performance by:
- machine-generating C code;
- compiling the generated code ahead-of-time with GCC;
- copying, patching and recombining pieces of native code at run time into executable memory.
Thank you for clarifying that Jitter and libgccjit are two competing but mutually exclusive or incompatible approaches to the same outcome of faster execution. Since it would be confusing to discuss both incompatible technologies in the same thread, let’s move the Jitter discussion to a new topic and track both threads, in case the libgccjit devs comment on this thread as I’ve invited them to do so. Octave can work with either / both. Competing ones are not a problem.
Happy to hear your thoughts on how Jitter would be implemented in Octave.
@siko1056 or anyone else who can split threads: pls move the Jitter comments, including this one, to a new thread.
I’d be glad to discuss ideas for improving the interpreter, whether by using a custom byte-code interpreter that is more efficient than the current parse tree evaluator, something like jitter to generate the code for the virtual machine, or a full JIT compiler.
@mnabipoor I have created an entry for you to discuss Jitter and VMs for the next Octave devs meeting. You can edit it. It will be on May 24 at 1800 UTC. Online Developer Meeting (2022-05-24) - Octave
One layperson question I have is that Octave when configured with
--enable-java loads the Java VM for certain operations. Can multiple VMs coexist or will they interfere?
@arungiridhar Thank you for this entry and putting the notes in the wiki (I have problem with creating an account there; I get “Incorrect or missing CAPTCHA.”).
It’s OK to have multiple VMs.
Jitter generates three files (1 .h and 2 .c files) which are the whole implementation of the VM (they use
libjitter.a (a static library) to provide ).
I’ll try to prepare a presentation for about 30 minutes to give an overview of Jitter and a small demo VM. And I also try to talk about
libgccjit and how can these two approaches can co-exist (which I think a good thing, at least as a performance baseline).
30 minutes might be too much, depending on how many other items for that meeting that will be added in the next two weeks. But do keep monitoring that wiki page and you can adjust your discussion points.
OK, I’ll try it to keep it short and provide more references for further reading/watching.
Do you still have problems with the wiki account creation? The mentioned error occurs when the Octave questions for spam protection is not correctly solved. I am sorry for the inconvenience and ask you to try this again.
I tried again, and it worked. Thanks.
It would also be helpful if you could provide something prior to the meeting for others to read so that everyone can have some background on what you are proposing before the meeting. I also encourage you to post those ideas here so we can start a discussion. That doesn’t have to wait for the meeting and is probably best to begin sooner rather than later. The meetings are typically pretty high level and we try to not get bogged down too much in technical details.