• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    Ruby
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Event Library (Fiber Scheduler) that designed for Ruby 3.0.

Evt

The Event Library that designed for Ruby 3.0 Fiber Scheduler.

This gem is still under development, APIs and features are not stable. Advices and PRs are highly welcome.

CI Tests Build Gem Version Downloads

Features

IO Backend Support

Linux Windows macOS FreeBSD
io_uring ⚠️ (See 1) ❌ ❌ ❌
epoll βœ… (See 2) ❌ ❌ ❌
kqueue ❌ ❌ βœ… (⚠️ See 5) βœ…
IOCP ❌ ❌ (⚠️See 3) ❌ ❌
Ruby (IO.select) βœ… (See 6) βœ… (⚠️See 4) βœ… (See 6) βœ… (See 6)
  1. when liburing is installed. (Currently fixing)
  2. when kernel version >= 2.6.9
  3. WOULD NOT WORK until FILE_FLAG_OVERLAPPED is included in I/O initialization process.
  4. Some I/Os are not able to be nonblock under Windows. Using POSIX select, SLOW. See Scheduler Docs.
  5. kqueue performance in Darwin is very poor. MAY BE DISABLED IN THE FUTURE.
  6. Using poll

Benchmark

The benchmark is running under v0.3.6 version. See example.rb in midori for test code, the test is running under a single-thread server.

The test command is wrk -t4 -c8192 -d30s http://localhost:8080.

All the systems have set their file descriptor limit to maximum. On systems raising "Fiber unable to allocate memory", sudo sysctl -w vm.max_map_count=1000000 is set.

OS CPU Memory Backend req/s
Linux Ryzen 2700x 64GB epoll 2035742.59
Linux Ryzen 2700x 64GB io_uring require fixes
Linux Ryzen 2700x 64GB IO.select (using poll) 1837640.54
macOS i7-6820HQ 16GB kqueue 257821.78
macOS i7-6820HQ 16GB IO.select (using poll) 338392.12

We also test the server with Redis request, with a monkey-patched redis library. The example code is following:

require 'evt'
require 'midori'
require 'midori-contrib/redic'

Fiber.set_scheduler Evt::Scheduler.new
REDIS = Redic.new

class HelloWorldAPI < Midori::API
  get '/' do
    REDIS.call 'GET', 'foo'
  end
end

Fiber.schedule do
  Midori::Runner.new(HelloWorldAPI).start
end

The benchmark result is as following:

OS CPU Memory Backend req/s
Linux Ryzen 2700x 64GB epoll 378060.30
macOS i7-6820HQ 16GB kqueue 204460.32

Install

gem install evt

Usage

require 'evt'

rd, wr = IO.pipe
scheduler = Evt::Scheduler.new

Fiber.set_scheduler scheduler

Fiber.schedule do
  message = rd.read(20)
  puts message
  rd.close
end

Fiber.schedule do
  wr.write("Hello World")
  wr.close
end

# "Hello World"

Roadmap

  • Support epoll/kqueue/select
  • Upgrade to the latest Scheduler API
  • Support io_uring
  • Support iov features of io_uring
  • Support IOCP (NOT ENABLED YET)
  • Setup tests with Ruby 3
  • Selectable backend compilation by environment variable
  • Support IOCP with iov features
  • Setup more tests for production purpose
  • Documentation for usages

More Repositories

1

ruby-relearning

γ€ŠRuby 再ε…₯ι—¨γ€‹οΌšδΈ€ζœ¬ε…³δΊŽι‡ζ–°ζ€θ€ƒηΌ–η¨‹ε…₯ι—¨ηš„ζ•™η¨‹
Ruby
102
star
2

quantum-i-ching

A Quantum 爻 System Implementation for Divination
Jupyter Notebook
93
star
3

fast-code

Encode/Decode plugin for Chrome
JavaScript
57
star
4

iptv-utils

A Shanghai Telecom IPTV Livestream Utility
Ruby
33
star
5

safaia-framework

Web Framework designed for cpp
C++
27
star
6

nihonchord

A Rime Nihongo Input Schema designed for ANSI keyboards using Chord Inputs.
Ruby
22
star
7

euc-jp

EUC-JP Encoding and Decoding Library for Dart Language
Dart
14
star
8

homophone-jokes-generator

Generate homophone jokes with trivial NLP techniques. θ°ιŸ³η¬‘θ―η”Ÿζˆ
Ruby
12
star
9

petri-dsl

A DSL for describing Petri-net
Ruby
9
star
10

rime-logic

A rime input method designed for logic. ηˆ²ι‚θΌ―η³»η΅±θ¨­θ¨ˆηš„ Rime θΌΈε…₯ζ–Ήζ‘ˆ
9
star
11

ksp-pilot

Ruby
9
star
12

busy

tell if I am busy
JavaScript
8
star
13

rime-bopomofo-symbols

η”¨ζ–ΌδΈ­ε·žιŸ»θΌΈε…₯ζ³¨ιŸ³ε’Œζ–ΉιŸ³η¬¦θ™Ÿηš„θΌΈε…₯法
8
star
14

petri-editor

An Visual Editor for Petri Net
Vue
8
star
15

minecraft-3d-printer

A rasterization playground
Ruby
7
star
16

my-general

Recover MySQL data from General Purpose Query Log
Ruby
6
star
17

is-the-order-algorithm

An Introduction to Algorithm
C++
5
star
18

websocket-chatroom

A websocket demo, based on Vue.js + sinatra
Ruby
5
star
19

crystal-boy

An Game boy Emulator Built with Crystal
Crystal
4
star
20

auto-mask

A demo on real-time facial recognition with face-api.js
JavaScript
3
star
21

photoelectron

I know nothing about CG.
C++
3
star
22

fairwork

Make web requests fair with PoW (Proof-of-work)
Ruby
3
star
23

goto-wiwivideos

去ε₯½ε’ŒεΌ¦θ―ζ’­ηΆ²θ§€ηœ‹
JavaScript
3
star
24

YAFL

Yet Another Flashcard Learner
Ruby
3
star
25

ubuntu-prototype-designer

Project for Ubuntu Hackathon Shanghai 2016
CSS
2
star
26

ippan-shain

General AI framwork built for gaming problems with ANN and MCTS, written in C++, support distributed computation
2
star
27

is-delton-awake-now

Given a page showing whether im awake or not
Ruby
2
star
28

oolong

Yet Another HTTP Server (Experimental)
Rust
2
star
29

binary-heap-sort

C#
2
star
30

blog

Ruby
2
star
31

music-classifier

Classify Music with Neural Network
Python
2
star
32

eye-tracker

Yet another some random neural network experiments
Python
2
star
33

buffer

The gem to operate low level I/O data buffer
C
2
star
34

perfcat

An open-source and free alternative to a Caniformia performance monitor tool, which collect and conCATenate PERFormance statistics of graphics applications.
C++
1
star
35

cocos-gal

DSL to create cross-platform interactive fiction game.
JavaScript
1
star
36

YetAnotherMe

Java
1
star
37

JapanGarbageClassification

Japan Garbage Classification
1
star
38

mini-wot

An open source W3C WoT Implementation for embedded devices in Rust
1
star
39

yetanother-fm

Yet Another FM
1
star
40

iro

iro is an AI automatically colour comics
Python
1
star
41

homo

Ingress Homogeneous Field Designer (Inspired by Konano/Ingress-Field-Design)
Rust
1
star
42

yukkikaze.js

[Deprecated] Yukkikaze.js is now a part of heckpsi-lab/noaj, this branch is no longer maintained.
JavaScript
1
star
43

env

This is a personal project for syncing my environment configurations between devices.
Shell
1
star
44

canto-measure

An similarity measurement on cantometrics data
Jupyter Notebook
1
star
45

2048-ai

An 2048 AI based on DQN
1
star
46

vibro

A software gamepad linear-vibration synthesizer
Jupyter Notebook
1
star
47

AutoNaive

AutoNaive is something that can automatically generate a passage in Jiang Ze-Ming styled words. Actually, that's nothing but a joke.
C#
1
star
48

ksp-ap

Auto Pilot System for KSP Aviation
Python
1
star
49

RaceTracker

RaceTracker is an car racing game(if you really believe it). Actually RaceTracker is more like a mathematical game. Winner takes less steps to finish a circuit. Allow custom maps.
Visual Basic
1
star