In multi-threaded ruby execution, you cannot get parallel execution of threads unless you use those functions which frees GVL.
In my understanding, following ruby methods frees GVL:
Kernel#sleep
IO#read
and IO#write
I asked same question on stackoverflow (Japanese).
Got this answer https://ja.stackoverflow.com/a/55579/754 , which stating that
- Bignum's div / modulo
- Dir.new/Dir.open
- Dir.chdir
- Dir.rmdir
- Dir.empty?
- Dir.glob
- File.chown
- File's methods which check file status, namely stats
- File.rename
- File.truncate
- File.mkfifo
- IO.copy_stream
- IO.#open and IO.#close related codes (was too complex to understand)
- Kernel.#system
- Kernel.#exec
and in other standard libraries such as fiddle, openssl, readline, socket, zlib actually calls method which frees GVL.
this great answer was written by https://stackoverflow.com/users/4944814/raccy