Ruby Compiler

Hi,

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.
1. Dump all symbols,ids and node tree to a file.
2. 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.

What do you think about this compiler?

Regards,

Park Heesob

···

--
Posted via http://www.ruby-forum.com/.

Looks interesting , one question:

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?)

Regards,

···

On 21 mar, 14:49, Heesob Park <pha...@gmail.com> wrote:

Hi,

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.
1. Dump all symbols,ids and node tree to a file.
2. 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.

What do you think about this compiler?

--
Luis Lavena

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.

···

On 22 Mrz., 05:11, Luis Lavena <luislav...@gmail.com> wrote:

On 21 mar, 14:49, Heesob Park <pha...@gmail.com> wrote:

> Hi,

> 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.
> 1. Dump all symbols,ids and node tree to a file.
> 2. 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.

> What do you think about this compiler?

Looks interesting , one question:

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?)

Hi,

···

----- Original Message -----
From: "Luis Lavena" <luislavena@gmail.com>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Saturday, March 22, 2008 7:15 AM
Subject: Re: Ruby Compiler

On 21 mar, 14:49, Heesob Park <pha...@gmail.com> wrote:

Hi,

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.
1. Dump all symbols,ids and node tree to a file.
2. 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.

What do you think about this compiler?

Looks interesting , one question:

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.

How it handles reload of files (using load 'foo.rb' compares the mtime
of the pre-compiled file with the source file?)

More work is needed for this problem. Currently it direcly loads the pre-compiled file.

Regards,
--
Luis Lavena

Regards,
Park Heesob

Hi,

···

----- Original Message -----
From: "llothar" <llothar@web.de>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Saturday, March 22, 2008 7:35 AM
Subject: Re: Ruby Compiler

On 22 Mrz., 05:11, Luis Lavena <luislav...@gmail.com> wrote:

On 21 mar, 14:49, Heesob Park <pha...@gmail.com> wrote:

> Hi,

> 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.
> 1. Dump all symbols,ids and node tree to a file.
> 2. 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.

> What do you think about this compiler?

Looks interesting , one question:

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?)

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.

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.

Regards,
Park Heesob

Hi,

···

In message "Re: Ruby Compiler" on Sat, 22 Mar 2008 09:56:28 +0900, "Park Heesob" <phasis68@hotmail.com> 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"?

              matz.

Hi,

···

----- Original Message -----
From: "Yukihiro Matsumoto" <matz@ruby-lang.org>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Saturday, March 22, 2008 10:42 AM
Subject: Re: Ruby Compiler

Hi,

In message "Re: Ruby Compiler" > on Sat, 22 Mar 2008 09:56:28 +0900, "Park Heesob" <phasis68@hotmail.com> 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"?

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.

matz.

Regards,
Park Heesob

Hi,

···

In message "Re: Ruby Compiler" on Sat, 22 Mar 2008 11:54:40 +0900, "Park Heesob" <phasis68@hotmail.com> 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.

Hi,

···

----- Original Message -----
From: "Yukihiro Matsumoto" <matz@ruby-lang.org>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Saturday, March 22, 2008 4:51 PM
Subject: Re: Ruby Compiler

Hi,

In message "Re: Ruby Compiler" > on Sat, 22 Mar 2008 11:54:40 +0900, "Park Heesob" <phasis68@hotmail.com> 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.

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.

Regards,
Park Heesob