agrafix / Rubyspeed
Compile ruby functions to C
Stars: ✭ 180
Programming Languages
Labels
Projects that are alternatives of or similar to Rubyspeed
Deepc
vendor independent deep learning library, compiler and inference framework microcomputers and micro-controllers
Stars: ✭ 260 (+44.44%)
Mutual labels: compiler, performance
Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (+103.89%)
Mutual labels: compiler, performance
Adlik
Adlik: Toolkit for Accelerating Deep Learning Inference
Stars: ✭ 237 (+31.67%)
Mutual labels: compiler, performance
Nuitka
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
Stars: ✭ 6,173 (+3329.44%)
Mutual labels: compiler, performance
Fastexpressioncompiler
Fast ExpressionTree compiler to delegate
Stars: ✭ 631 (+250.56%)
Mutual labels: compiler, performance
Delta
Programming language focused on performance and productivity
Stars: ✭ 77 (-57.22%)
Mutual labels: compiler, performance
Clang
Mirror kept for legacy. Moved to https://github.com/llvm/llvm-project
Stars: ✭ 2,880 (+1500%)
Mutual labels: compiler, performance
Halide
a language for fast, portable data-parallel computation
Stars: ✭ 4,722 (+2523.33%)
Mutual labels: compiler, performance
Nimporter
Compile Nim Extensions for Python On Import!
Stars: ✭ 474 (+163.33%)
Mutual labels: compiler, performance
Tvm
Open deep learning compiler stack for cpu, gpu and specialized accelerators
Stars: ✭ 7,494 (+4063.33%)
Mutual labels: compiler, performance
Command Block Assembly
Compile high-level code into Minecraft commands
Stars: ✭ 175 (-2.78%)
Mutual labels: compiler
Corewar
A reproduction of the Core War game. Assembly compiler, Virtual Machine and GUI.
Stars: ✭ 173 (-3.89%)
Mutual labels: compiler
Fe Performance Journey
🚵 a Journey of Performance Optimizing in Frontend 🚀
Stars: ✭ 169 (-6.11%)
Mutual labels: performance
Xl
A minimalist, general-purpose programming language based on meta-programming and parse tree rewrites
Stars: ✭ 171 (-5%)
Mutual labels: compiler
Fiber
⚡️ Express inspired web framework written in Go
Stars: ✭ 17,334 (+9530%)
Mutual labels: performance
Rubyspeed
Work in progress.
Welcome to Rubyspeed. Right now, Rubyspeed is a basic proof of concept (horribly hacked together) that allows annotating method declarations to automatically be specialized and compiled to C. Here's an example:
require 'rubyspeed'
class TestClass
extend(Rubyspeed::Compiles)
compile!(params: [Rubyspeed::T.array(Rubyspeed::T.int), Rubyspeed::T.array(Rubyspeed::T.int)], return_type: Rubyspeed::T.int)
def self.dot(a, b)
c = Rubyspeed::Let.int(0)
a.each_with_index do |a_val, idx|
c += a_val * b[idx]
end
c
end
end
This will automatically replace the dot
implementation with a compiled C version, that runs quite a bit (5x) faster than the native ruby version:
$ rake bench
user system total real
compiled 0.000021 0.000004 0.000025 ( 0.000018)
ruby 0.000105 0.000002 0.000107 ( 0.000103)
How does this work?
In short:
- Use a neat annotation trick inspired by the sorbet runtime to emulate annotations (compare to
@Deprecated
in Java for example) - Extract the ruby source from the given method
- Transform it to s-expressions
- Generate C code from the s-expressions
- Use a C compiler to compile to a ruby module
- Replace original implementation with a call to the compiled ruby module
Inspiration
This project was inspired by Stephen Diehl's LLVM specializer for Python and rubyinline.
Current Status
The project can only compile extremely primitive functions (basically only simple numeric computations). I am open to any pull requests for improvements, but would discourage using this in production anywhere :-)
Hacking
$ bundle install
$ rake test # run the tests
$ rake bench # run the benchmarks
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].