# Performance issues with json\_pure under IronRuby

**URL:** <https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448>\
**Category:** IronRuby\
**Created:** [July 30, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448 "2010-07-30T13:11:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [July 30, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448/1 "2010-07-30T13:11:16Z")

</div>

Hi,  
yesterday I was testing the json library under IronRuby and,  
comparisons with other implementations aside, I noticed that the  
“pure” variant performs so bad under IronRuby that it just doesn’t  
feel normal at all. This is the result for my test with a ~500KB JSON  
file parsed under IronRuby 1.1.0 (.NET 4):

C:\IronRuby\v1.1.0\>ir json\_speed.rb pure  
Rehearsal ------------------------------------  
474.906250 39.421875 514.328125 (394.262696)  
------------------------- total: 514.328125sec

```
   user system total real

```

482.531250 43.140625 525.671875 (384.509766)

Here is the full gist with also the results for the same test run  
using other implementations (JRuby 1.5 and the latest MRI 1.8.6):

> <https://gist.github.com/nrk/498997>
>
> There are more than three files. show original

I haven’t figured yet where the bottleneck is, and the fact that it’s  
slower on the second run makes things even weirder since the cold  
execution overhead shouldn’t be there anymore. Any idea about why is  
it so slow?

–  
Daniele A.  
[http://clorophilla.net/](http://clorophilla.net/)  
[http://twitter.com/JoL1hAHN](http://twitter.com/JoL1hAHN)

---

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [July 30, 2010, 10:11pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448/2 "2010-07-30T22:11:04Z")

</div>

I’ve narrowed the problem down. It’s somewhere in the  
StringScanner.Match  
method (probably inside RubyRegex.Match).

The next IR code (I’ve put in on pastebin) results with the same  
performance  
problem where MRI is about 100 (!) times faster than IronRuby:  
[http://pastebin.com/cc9FvUfz](http://pastebin.com/cc9FvUfz).

Shay.

---

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [July 30, 2010, 10:47pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448/3 "2010-07-30T22:47:57Z")

</div>

Done - [http://ironruby.codeplex.com/workitem/4966](http://ironruby.codeplex.com/workitem/4966)

Shay.

On Fri, Jul 30, 2010 at 11:17 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [July 30, 2010, 10:35pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448/4 "2010-07-30T22:35:39Z")

</div>

Great work. Could you file a bug so that we track this perf issue?

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Shay F.  
Sent: Friday, July 30, 2010 12:37 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Performance issues with json\_pure under  
IronRuby

I’ve narrowed the problem down. It’s somewhere in the  
StringScanner.Match method (probably inside RubyRegex.Match).

The next IR code (I’ve put in on pastebin) results with the same  
performance problem where MRI is about 100 (!) times faster than  
IronRuby: [http://pastebin.com/cc9FvUfz](http://pastebin.com/cc9FvUfz).

Shay.

On Fri, Jul 30, 2010 at 2:03 PM, Daniele A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:  
Hi,  
yesterday I was testing the json library under IronRuby and,  
comparisons with other implementations aside, I noticed that the  
“pure” variant performs so bad under IronRuby that it just doesn’t  
feel normal at all. This is the result for my test with a ~500KB JSON  
file parsed under IronRuby 1.1.0 (.NET 4):

C:\IronRuby\v1.1.0\>ir json\_speed.rb pure  
Rehearsal ------------------------------------  
474.906250 39.421875 514.328125 (394.262696)  
------------------------- total: 514.328125sec

```
  user system total real

```

482.531250 43.140625 525.671875 (384.509766)

Here is the full gist with also the results for the same test run  
using other implementations (JRuby 1.5 and the latest MRI 1.8.6):

> <https://gist.github.com/nrk/498997>
>
> There are more than three files. show original

I haven’t figured yet where the bottleneck is, and the fact that it’s  
slower on the second run makes things even weirder since the cold  
execution overhead shouldn’t be there anymore. Any idea about why is  
it so slow?

–  
Daniele A.  
[http://clorophilla.net/](http://clorophilla.net/)  
[http://twitter.com/JoL1hAHN](http://twitter.com/JoL1hAHN)

---

<div class="post-metadata">

**Author:** ![murena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@murena](https://www.ruby-forum.com/u/murena)\
**Post date:** [July 31, 2010, 6:43pm UTC](https://www.ruby-forum.com/t/performance-issues-with-json-pure-under-ironruby/192448/5 "2010-07-31T18:43:37Z")

</div>

Just added a comment on the bugtracker for this issue, it seems like  
the /n modifier in the regexp is the cause of the abnormal slow down.

On Fri, Jul 30, 2010 at 22:41, Shay F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > yesterday I was testing the json library under IronRuby and,  
> > Â Â Â user Â Â system Â Â Â total Â Â Â Â real
> 
> [http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Daniele A.

> **[clorophilla.net](https://clorophilla.net/)**

[http://twitter.com/JoL1hAHN](http://twitter.com/JoL1hAHN)
