From: Eric Mahurin Date: 2008-02-12T04:07:53+09:00 Subject: Re: very bad character performance on ruby1.9 ------=_Part_39872_11474002.1202756879894 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Feb 11, 2008 11:51 AM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: very bad character performance on ruby1.9" > on Mon, 11 Feb 2008 03:33:54 +0900, "Eric Mahurin" < > eric.mahurin@gmail.com> writes: > > |I'd like to bring up the issue of how characters are represented in > |ruby 1.9from a performance standpoint. In a recent ruby-quiz (parsing > |JSON), the > |fastest pure-ruby solution was simply an LL(1) parser that looked at one > |character at a time (it beat various Regexp solutions). With ruby 1.9, > the > |runtime increased by 4X making it a slow solution. A simple benchmark is > at > |the end of this message that counts words in an LL(1) fashion. With ruby > |1.8.6, it can could the words in Homer's Iliad in 1.46s on my machine and > in > |ruby 1.9 (from ubuntu gutsy) it takes 52.87s (36X increase in runtime). > > I just checked in some performance tweaking. The script run still > slower (2.3 times), but much better than 36 times. It is nice for two > hour job. This sounds much better. Thank you, matz! Am I correct in assuming that the remaining ruby 1.9 slowness relative to ruby 1.8.6 is due to each character access creating a new object? Might it be possible to reuse "character" objects? Making characters or short immutable strings immediate would be ideal for this, but some type of lookup of existing character objects could also be done. Eric ------=_Part_39872_11474002.1202756879894 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Feb 11, 2008 11:51 AM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,

In message "Re: very bad character performance on ruby1.9"
   on Mon, 11 Feb 2008 03:33:54 +0900, "Eric Mahurin" <eric.mahurin@gmail.com> writes:

|I'd like to bring up the issue of how characters are represented in
|ruby 1.9from a performance standpoint.  In a recent ruby-quiz (parsing
|JSON), the
|fastest pure-ruby solution was simply an LL(1) parser that looked at one
|character at a time (it beat various Regexp solutions).  With ruby 1.9, the
|runtime increased by 4X making it a slow solution.  A simple benchmark is at
|the end of this message that counts words in an LL(1) fashion.  With ruby
|1.8.6, it can could the words in Homer's Iliad in 1.46s on my machine and in
|ruby 1.9 (from ubuntu gutsy) it takes 52.87s (36X increase in runtime).

I just checked in some performance tweaking.  The script run still
slower (2.3 times), but much better than 36 times.  It is nice for two
hour job.

This sounds much better.  Thank you, matz!

Am I correct in assuming that the remaining ruby 1.9 slowness relative to ruby 1.8.6 is due to each character access creating a new object?  Might it be possible to reuse "character" objects?   Making characters or short immutable strings immediate would be ideal for this, but some type of lookup of existing character objects could also be done.

Eric

------=_Part_39872_11474002.1202756879894--