In the same vein as https://bugs.ruby-lang.org/issues/13996
There's 4 more patches to dir.c around opendir, readdir, openat,
and chdir.
I don't think releasing GVL around rewinddir is necessary, since
AFAIK; it's just an lseek and that only updates an offset in the
kernel.
Releasing GVL around closedir may not be needed, either, since
it's operations on that FD are read-only; I'll have to read
Linux kernel sources around various FSes to confirm; but also
modern versions of Linux defer a lot of the complicated close()
stuff, anyways, to reduce userspace syscall time.
However, releasing GVL around mkdir and rmdir will be necessary,
of course; as well as the remaining stat/lstat calls in dir.c
It also looks like the dir glob code could be doing multiple
syscalls and non-rb_* userspace stuff without GVL to reduce
overhead of releasing/acquiring the GVL too frequently; but
that's a more involved patch and UTF-8 normalizing FS platforms
won't benefit (but they're not my top priority performance-wise,
either).
The following changes since commit 593d9786464c94db9c776a5a968dcf65cbc1d9d4:
tempfile.rb: [DOC] all arguments [ci skip] (2017-10-17 12:40:00 +0000)
are available in the git repository at:
git://80x24.org/ruby dir-file-gvl-r60203
for you to fetch changes up to 859716bb3a0bc2057a2d0f05079e480a1955e36c:
dir: Dir.chdir releases GVL (2017-10-18 01:59:48 +0000)
Eric Wong (5):
file.c: apply2files releases GVL
dir.c: release GVL around remaining readdir calls
dir.c: release GVL on opendir
dir.c: openat calls release GVL, too
dir: Dir.chdir releases GVL
benchmark/bm_file_chmod.rb | 9 +++
dir.c | 195 ++++++++++++++++++++++++++++++++-------------
file.c | 159 +++++++++++++++++++++++++-----------
3 files changed, 261 insertions(+), 102 deletions(-)
create mode 100644 benchmark/bm_file_chmod.rb