I longed for a ruby byte code compiler.
But I guess YARV is not stable until now.
So I made a very experimental Ruby Compiler.
Actually it is not a true compiler just ruby object dumper and loader.
By modifing gc.c and eval.c , It cannot be distibuted as extension
library.
The main idea is simple.
Dump all symbols,ids and node tree to a file.
Load the symbols,ids and tree from a file and run.
But I should have spent much time to understand how to parsing and
evalualing
the ruby code.
With this compiler, you can secure your source code.
And saving parsing time is the main advantage.
Even the same object file can runs on Linux and Windows just like Java
class.
Does the loading for the parsed/node tree generated dump avoid
evaluation? I mean, there is no need to reparse it, right? If so, then
you have a speed boost when loading pre-compiled ruby scripts and
sounds good.
How it handles reload of files (using load ‘foo.rb’ compares the mtime
of the pre-compiled file with the source file?)
Actually it is not a true compiler just ruby object dumper and loader.
evaluation? I mean, there is no need to reparse it, right? If so, then
you have a speed boost when loading pre-compiled ruby scripts and
sounds good.
How it handles reload of files (using load ‘foo.rb’ compares the mtime
of the pre-compiled file with the source file?)
This concept can only work on special written files that are not doing
any
evaluation during load. Unfortunately almost none of the files in the
standard library do fit into this schema.
Hi,
----- Original Message -----
From: “llothar” [email protected]
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” [email protected]
Sent: Saturday, March 22, 2008 7:35 AM
Subject: Re: Ruby Compiler
So I made a very experimental Ruby Compiler.
the ruby code.
Does the loading for the parsed/node tree generated dump avoid
evaluation during load. Unfortunately almost none of the files in the
standard library do fit into this schema.
I don’t think so. My compiler is just dump and load the first parsed
node tree snapshot.
So you can use it for all case regardless of evaluation during load.
It is same to the ruby interpreter except for the source is parsed or
not.
In message “Re: Ruby Compiler”
on Sat, 22 Mar 2008 09:56:28 +0900, “Park H.” [email protected] writes:
|> Does the loading for the parsed/node tree generated dump avoid
|> evaluation? I mean, there is no need to reparse it, right? If so, then
|> you have a speed boost when loading pre-compiled ruby scripts and
|> sounds good.
|>
|Yes, of course. The main purpose is speed up.
Have you measured the performance of the “compiler”?
Hi,
----- Original Message -----
From: “Yukihiro M.” [email protected]
To: “ruby-talk ML” [email protected]
Sent: Saturday, March 22, 2008 10:42 AM
Subject: Re: Ruby Compiler
|Yes, of course. The main purpose is speed up.
Have you measured the performance of the “compiler”?
Actually the performance is not as good as I expected.
For the simple source code, the peformance is not better than ruby
interpreter.
If the parsing time takes longer, the performance is better enough.
I guess the web environment ruby code like Ruby On Rails can have some
performance gain.
Hi,
----- Original Message -----
From: “Yukihiro M.” [email protected]
To: “ruby-talk ML” [email protected]
Sent: Saturday, March 22, 2008 4:51 PM
Subject: Re: Ruby Compiler
|I guess the web environment ruby code like Ruby On Rails can have some performance gain.
Last time I have benchmarked, parsing time was not significant. I am
very interested in how much this approach works for what kind of
situation, say RoR.
I realized the parsing time is not an issue of performance after several
tests.
So the performance gain with skipping parsing might be just a vain
efforts.
For the real speed up, I believe the optimization of node tree is
required.
Thank you for your attention.
In message “Re: Ruby Compiler”
on Sat, 22 Mar 2008 11:54:40 +0900, “Park H.” [email protected] writes:
|> Have you measured the performance of the “compiler”?
|
|Actually the performance is not as good as I expected.
|For the simple source code, the peformance is not better than ruby interpreter.
|If the parsing time takes longer, the performance is better enough.
|I guess the web environment ruby code like Ruby On Rails can have some performance gain.
Last time I have benchmarked, parsing time was not significant. I am
very interested in how much this approach works for what kind of
situation, say RoR.
matz.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.