Project

General

Profile

Actions

Bug #8399

closed

Remove usage of RARRAY_PTR in C extensions when not needed

Added by dbussink (Dirkjan Bussink) almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
trunk
[ruby-core:54939]

Description

Rubinius uses quite a few C extensions directly from MRI. Some of these use functionality such as RARRAY_PTR which is not necessary. For compatibility reasons, RARRAY_PTR works on Rubinius but suffers from a heavy performance penalty. Take for example the test of the parser gem (http://github.com/whitequark/parser). These run over 10x faster with the patch applied to Racc that is submitted here:

https://gist.github.com/dbussink/57c32c08fb21c7a41719

Consider issue #8339 where there is work being done on generational GC, I think it is also beneficial to remove usage of internal structures such as RARRAY_PTR where there is the problem of going around the write barrier. In Rubinius, an array is treated special if RARRAY_PTR is used on it in the C-API, so I can imagine MRI being able to optimize the GC better if extensions don't do this. There are functions available for both getting and setting elements in an array and they work fine.

I have only make a patch against Racc here as a showcase, I also want to update all the other extensions to remove RARRAY_PTR. Please consider this change to MRI since in my opinion it has benefits also for MRI and so Rubinius can keep using these extensions directly without having to maintain custom versions just for the considerations described here. I'm also already actively checking C extension gems and sending pull requests for updating this.


Files

racc.patch (4.71 KB) racc.patch dbussink (Dirkjan Bussink), 05/13/2013 05:37 AM
racc.patch (4.79 KB) racc.patch dbussink (Dirkjan Bussink), 05/13/2013 02:40 PM
racc.patch (4.68 KB) racc.patch dbussink (Dirkjan Bussink), 06/08/2013 06:47 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #8339: Introducing Geneartional Garbage Collection for CRuby/MRIClosedko1 (Koichi Sasada)04/28/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0