GithubHelp home page GithubHelp logo

sisshiki1969 / monoruby Goto Github PK

View Code? Open in Web Editor NEW
106.0 4.0 4.0 12.83 MB

Ruby implementation with yet another JIT compiler.

License: Apache License 2.0

Rust 94.69% Ruby 4.91% JavaScript 0.01% Lua 0.01% Shell 0.38% C 0.01%

monoruby's Introduction

monoruby

Rust codecov

Ruby implementation with yet another JIT compiler written in Rust.

Presentation

Presentation slides for RubyKaigi2024 are here.

Features

  • Written in Rust from scratch. No dependencies on any other Ruby implementations.
  • Fast. Currently, monoruby is comparable to ruby3.3.0+YJIT in the optcarrot benchmark.
  • Hand-written original parser.
  • Register-based bytecode.
  • Bytecode executor (virtual machine) written in x86-64 assembly (yes, we currently support only x86-64!).
  • A compact and fast just-in-time compiler. (internally using self-made dynamic assembler monoasm)

Prerequisites

Platform

Currently, only x86-64/linux is supported.

Build

To build monoruby, You'll need installation of Rust. Please be aware that only nightly Rust works for monoruby.

Check here to install Rust, and see here to work with nightly Rust.

How to run

To run ruby program file on monoruby,

> cargo run test.rb

or

> cargo run --release -- test.rb

one liner.

> cargo run -- -e "puts 100"

And also, you can launch REPL.

> cargo run --bin irm

or

> bin/irm

How to install

To install monoruby,

> cargo install --path monoruby

Now, you can play with monoruby,

> monoruby test.rb

and its REPL.

> irm

Benchmark

machine spec

  • Architecture: x86_64
  • CPU(s): 32
    • Model name: 13th Gen Intel(R) Core(TM) i9-13900HX
    • Thread(s) per core: 2
    • Core(s) per socket: 16
  • Caches (sum of all):
    • L1d: 768 KiB (16 instances)
    • L1i: 512 KiB (16 instances)
    • L2: 32 MiB (16 instances)
    • L3: 36 MiB (1 instance)

optcarrot

Several Ruby implementations described below were measured by optcarrot benchmark.

  • ruby 3.4.0dev (2024-04-27T08:56:20Z master 9ea77cb351) [x86_64-linux]
  • truffleruby 24.0.1, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-linux]
  • truffleruby 24.0.1, like ruby 3.2.2, Oracle GraalVM Native [x86_64-linux]
  • monoruby: 3e348afd4141c40978342e67ad26d42dc0b8d2a7

optcarrot benchmark

optcarrot_benchmark

optcarrot fps history (0-3000 frames)

optcarrot_fps_history

with --opt option (self-rewriting optimization mode)

optcarrot_fps_history

micro benchmark

  • measured by benchmark-driver with '--repeat-count 3' option.
  • benchmark codes are in the official repo and plb2.
  • measurements are shown in iteration/sec (the higher, the better).
  • warm up cycles prior to measurement; 50 cycles for mandelbrot and 200 cycles for nbody. (see benchmark/so_mandelbrot.yml and so_nbody.yml)
3.4-dev 3.4-dev --yjit truffleruby+graalvm-24.0.1 truffleruby-24.0.1 monoruby monoruby --no-jit
app_fib 5.473 41.195 6.988 27.447 39.174 9.912
mandelbrot 0.980 1.983 8.662 10.833 29.979 1.044
nbody 1.736 4.543 80.551 90.610 15.966 1.301
app_aobench 0.049 0.094 0.276 0.346 0.305 0.044
nqueen 0.015 0.015 0.206 0.193 0.150 0.021
sudoku 0.018 0.077 0.207 0.238 0.133 0.020
matmul 0.010 0.023 0.332 0.347 0.062 0.007
bedcov 0.033 0.049 0.222 0.257 0.048 0.033

ratio to CRuby 3.4-dev were shown in the graph below.

micro_bench

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.