Koichi Sasada d65d2fb6b5 Do not poll first
Before this patch, the MN scheduler waits for the IO with the
following steps:

1. `poll(fd, timeout=0)` to check fd is ready or not.
2. if fd is not ready, waits with MN thread scheduler
3. call `func` to issue the blocking I/O call

The advantage of advanced `poll()` is we can wait for the
IO ready for any fds. However `poll()` becomes overhead
for already ready fds.

This patch changes the steps like:

1. call `func` to issue the blocking I/O call
2. if the `func` returns `EWOULDBLOCK` the fd is `O_NONBLOCK`
   and we need to wait for fd is ready so that waits with MN
   thread scheduler.

In this case, we can wait only for `O_NONBLOCK` fds. Otherwise
it waits with blocking operations such as `read()` system call.
However we don't need to call `poll()` to check fd is ready
in advance.

With this patch we can observe performance improvement
on microbenchmark which repeats blocking I/O (not
`O_NONBLOCK` fd) with and without MN thread scheduler.

```ruby
require 'benchmark'

f = open('/dev/null', 'w')
f.sync = true

TN = 1
N = 1_000_000 / TN

Benchmark.bm{|x|
  x.report{
    TN.times.map{
      Thread.new{
        N.times{f.print '.'}
      }
    }.each(&:join)
  }
}
__END__
TN = 1
                 user     system      total        real
ruby32       0.393966   0.101122   0.495088 (  0.495235)
ruby33       0.493963   0.089521   0.583484 (  0.584091)
ruby33+MN    0.639333   0.200843   0.840176 (  0.840291) <- Slow
this+MN      0.512231   0.099091   0.611322 (  0.611074) <- Good
```
2024-01-05 05:51:25 +09:00
2023-12-28 23:53:15 +09:00
2024-01-05 05:51:25 +09:00
2024-01-02 14:19:42 +09:00
2023-12-07 15:52:35 -05:00
2023-12-27 11:11:42 -05:00
2024-01-02 14:19:42 +09:00
2023-12-07 15:52:35 -05:00
2023-12-19 13:09:36 -08:00
2024-01-04 17:47:26 +09:00
2024-01-02 14:19:42 +09:00
2023-12-25 22:10:20 -05:00
2023-12-18 20:17:43 +09:00
GPL
2024-01-04 11:25:31 -05:00
2024-01-05 05:51:25 +09:00
2023-12-15 13:42:19 -05:00
2023-12-17 00:21:00 +09:00
2023-12-07 15:52:35 -05:00
2023-12-07 15:52:35 -05:00
2024-01-02 14:19:42 +09:00
2024-01-02 14:19:42 +09:00
2024-01-02 14:19:42 +09:00
2023-12-15 11:58:43 +09:00
2024-01-02 09:13:43 -08:00
2023-12-12 17:24:17 -05:00
2023-12-07 15:52:35 -05:00
2023-12-27 19:31:56 -05:00
2024-01-05 05:51:25 +09:00
2023-12-22 22:18:14 -08:00
2024-01-02 14:19:42 +09:00
2024-01-02 14:19:42 +09:00
2023-12-04 13:57:12 -05:00
2023-12-07 15:52:35 -05:00
2024-01-05 05:51:25 +09:00
2023-12-02 21:48:00 +09:00
2023-12-02 21:48:00 +09:00
2023-12-07 15:52:35 -05:00
2023-12-07 15:52:35 -05:00
2023-12-15 13:42:19 -05:00
2024-01-05 05:51:25 +09:00
2024-01-03 15:41:08 -05:00
2023-12-07 09:23:02 -08:00

Actions Status: MinGW Actions Status: RJIT Actions Status: Ubuntu Actions Status: Windows AppVeyor status Travis Status

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address ruby-talk-request@ml.ruby-lang.org.

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

matz@ruby-lang.org

Description
Languages
Ruby 58.9%
C 29.7%
Rust 4%
C++ 3%
Makefile 2.1%
Other 2.2%