Project

General

Profile

Actions

Feature #13958

closed

[PATCH] Dir.empty? releases GVL

Added by normalperson (Eric Wong) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:83071]

Description

This converts all slow syscalls in the Dir.empty? implementation
to release GVL. We avoid unnecessarily GVL release and
reacquire for each slow call (opendir, readdir, closedir) and
instead only release and acquire the GVL once in the common
case.

  • dir.c (rb_gc_for_fd_with_gvl): new function
    (nogvl_dir_empty_p): ditto
    (dir_s_empty_p): use new functions to release GVL

Files

0001-Dir.empty-releases-GVL.patch (3.08 KB) 0001-Dir.empty-releases-GVL.patch normalperson (Eric Wong), 10/01/2017 04:24 AM

Updated by normalperson (Eric Wong) over 6 years ago

wrote:

https://bugs.ruby-lang.org/issues/13958

Updated with benchmark:
https://80x24.org/spew/20171002183339.30098-1-e@80x24.org/raw

Benchmarks from my old Pentium M 1.6GHz:

Benchmark results show a small degradation in single-threaded
performance:
Execution time (sec)
name trunk built
dir_empty_p 0.689 0.758

Speedup ratio: compare with the result of `trunk' (greater is better)
name built
dir_empty_p 0.909

Actions #2

Updated by Anonymous over 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60111.


Dir.empty? releases GVL

This converts all slow syscalls in the Dir.empty? implementation
to release GVL. We avoid unnecessarily GVL release and
reacquire for each slow call (opendir, readdir, closedir) and
instead only release and acquire the GVL once in the common
case.

Benchmark results show a small degradation in single-threaded
performance:
Execution time (sec)
name trunk built
dir_empty_p 0.689 0.758

Speedup ratio: compare with the result of `trunk' (greater is better)
name built
dir_empty_p 0.909

  • dir.c (rb_gc_for_fd_with_gvl): new function
    (nogvl_dir_empty_p): ditto
    (dir_s_empty_p): use new functions to release GVL
  • benchmark/bm_dir_empty_p.rb: new benchmark
    [ruby-core:83071] [Feature #13958]
Actions

Also available in: Atom PDF

Like0
Like0Like0