Skip to content

New Approach to C/Java Native Extensions #186

Closed
@jdantonio

Description

@jdantonio

Now that we've had C/Java native extensions in the latest release for a few months, they have proven to be as big of a pain as I expected. For the next major release I suggest that we move all C and Java native code into the ruby-atomic gem, keep concurrent-ruby pure Ruby, have this gem detect the presence of ruby-atomic when installed, and use the optimized native code when present. Additionally, I suggest we use the current automated build process to build pre-compiled versions of ruby-atomic, but allow for compilation of extensions on install (which we currently do not do for concurrent-ruby).

A few other approaches have been suggested in other threads. Lets use this thread to discuss alternatives and make a decision.

The big problem posed by native extensions is obtaining a consistent build across all platforms. We've been able to manage this for many platforms by creating the pre-compiled builds. Things work as expected on Windows, JRuby, Rubinius, and standard Linux (Ubuntu and CentOS) installations. We have had problems on OS X (Issue #170) and Heroku (Issue #181). In both cases the pure-Ruby code is used even when the target platform supports compilations.

It is important to note that the issues #170 and #181 are the result of an intentional decision. Expecting a gem to compile on installation often causes problems because the necessary build tools may not be installed on the target system. This becomes an unrecoverable error that prevents installation of the gem. Even when the necessary build tools can be easily installed, many DevOps professionals prefer not to. Installing build tools on a production system is considered a security issue by many.

Although many applications will benefit by the performance improvements provided by the native code, many do not need them. Additionally, interpreters other than MRI and JRuby (such as Rubinius) cannot use the extensions anyway. Moving the native code into a different gem and making it optional seems like the most problem-free approach.

Metadata

Metadata

Assignees

Labels

questionAn user question, does not change the library.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions