Skip to content

Running C extensions natively #3118

Closed
Closed
@eregon

Description

@eregon

We want to experiment with running C extensions natively instead of on Sulong.
Similar to what GraalPython did for 23.0.
We might still run libtruffleruby on Sulong, or at least initially we would because this is much easier.

  • This should improve compatibility with bigger extensions such as grpc which are proving difficult to run on Sulong due to the very large amount of C/C++/etc code they run.
  • This would eliminate warmup for native extensions.
  • It will speed up native compilation by not needing bitcode
  • It can reuse the compiler toolchain of the host system, which means we would not need the llvm toolchain anymore (saves disk space) if this mode is good enough to replace running C extensions on Sulong
  • Peak performance might be lower for some extensions which benefit from fast C->Ruby and Ruby->C calls, due to having to create handles for every Ruby->C call and going through NFI/JNI/Panama for C->Ruby calls. OTOH, the native code in the extension might run faster as Sulong e.g. reimplements vector instructions. We will need to benchmark this.
  • Some struct accesses cannot be virtualized by Sulong anymore and so these structs likely either can't be supported or we need to allocate a native struct and copy there (for read-only fields, because writing to them would have no effect). Hopefully very few extensions rely on direct struct access. The Ruby C API seems to have very few exposed structs.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions