Project

General

Profile

Actions

Bug #15633

closed

Pathological slowdown in File.expand_path on UNC paths on Windows

Added by djberg96 (Daniel Berger) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
[ruby-core:91656]

Description

For a while now, including Ruby 2.5, calling File.expand_path on an absolute UNC path seems to be strangely slow. I've put together some benchmarks here:

require 'benchmark'

MAX = 200000

Benchmark.bm(30) do |x|
  x.report("expand_path('foo/bar')") do
    str = "foo/bar"
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('C:/foo/bar')") do
    str = "C:/foo/bar"
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('//foo/bar')") do
    str = "//foo/bar"
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('foo//bar///')") do
    str = "foo//bar///"
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('~')") do
    str = "~"
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('')") do
    str = ""
    MAX.times{ File.expand_path(str) }
  end

  x.report("expand_path('', '~')") do
    MAX.times{ File.expand_path('', '~') }
  end
end

What I see is that most of these take only a second or two, while the UNC path takes 30+ seconds.

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r67163.


FindFirstFile cannot glob share names

  • win32/file.c (replace_to_long_name): do not try to glob host
    names and share names by FindFirstFile which is useless for that
    purpose. [ruby-core:91656] [Bug #15633]
Actions

Also available in: Atom PDF

Like0
Like0