https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112023-01-30T03:19:45ZRuby Issue Tracking SystemRuby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1015472023-01-30T03:19:45Zaidog (Andi Idogawa)andi@idogawa.com
<ul><li><strong>File</strong> <a href="/attachments/9398">windows-no-realpath-require.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/9398/windows-no-realpath-require.patch">windows-no-realpath-require.patch</a> added</li></ul><p>Thanks to the new windows build docs by ioquatix, I made a test patch to check how much faster it would be if some of the repeated syscalls on the folders (c:/tmp/, c:/tmp/speedtest, gems and so on) are avoided:</p>
<p>tzinfo: 0.8s to 0.3s<br>
gtk3: 2.8s to 2.5s (I see another similar issue inside the gem C code)</p>
<p>Windows has GetFinalPathNameByHandleW since Vista, which <a href="https://github.com/JuliaLang/julia/issues/30588" class="external">some other projects</a> use for realpath. Would it work for Ruby?</p> Ruby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1016862023-02-07T06:35:52Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>windows</i></li></ul> Ruby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1020152023-02-24T01:43:12Zjoshc (Josh C)josh.nw@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/9408">windows-revert-79a4484a.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/9408/windows-revert-79a4484a.patch">windows-revert-79a4484a.patch</a> added</li></ul><p>I've also noticed a significant increase in file IO events (as reported by procmon) due to <a href="https://github.com/ruby/ruby/commit/79a4484a072e9769b603e7b4fbdb15b1d7eccb15" class="external">https://github.com/ruby/ruby/commit/79a4484a072e9769b603e7b4fbdb15b1d7eccb15</a> introduced in Ruby 3.1.0. The code tries to prevent the same file from being loaded twice by calling <code>rb_realpath_internal</code> to see if the realpath has already been loaded. This is a problem on systems like Windows that use Ruby's emulated realpath, especially when there are deeply nested directories. I've attached a revert patch. It'd be great to use GetFinalPathNameByHandleW and avoid the emulate code.</p> Ruby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1020162023-02-24T02:22:38Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>joshc (Josh C) wrote in <a href="#note-3">#note-3</a>:</p>
<blockquote>
<p>I've attached a revert patch.</p>
</blockquote>
<p>I think the only way we would revert <a class="changeset" title="Do not load file with same realpath twice when requiring This fixes issues with paths being load..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/79a4484a072e9769b603e7b4fbdb15b1d7eccb15">79a4484a072e9769b603e7b4fbdb15b1d7eccb15</a> is if someone can come up with an alternative approach to fixing Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: require_relative and require should be compatible with each other when symlinked files are used (Closed)" href="https://bugs.ruby-lang.org/issues/17885">#17885</a>.</p>
<blockquote>
<p>It'd be great to use GetFinalPathNameByHandleW and avoid the emulate code.</p>
</blockquote>
<p>If you mean to use this on Windows for the internals of File#realpath, I think we would be open to a backwards compatible patch for that, but <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/9">@usa (Usaku NAKAMURA)</a> would need to decide as he maintains the mswin64 platform.</p> Ruby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1020832023-02-28T20:25:00ZMSP-Greg (Greg L)
<ul></ul><p>Code using <code>GetFinalPathNameByHandleW</code> already exists in win32/win32.c, see</p>
<p><a href="https://github.com/ruby/ruby/blob/c43fbe4ebd2b519601f0b90ca98fa096799d3846/win32/win32.c#L2013-L2022" class="external">https://github.com/ruby/ruby/blob/c43fbe4ebd2b519601f0b90ca98fa096799d3846/win32/win32.c#L2013-L2022</a></p>
<p>For cross-reference, see also <a href="https://bugs.ruby-lang.org/issues/19246" class="external">Bug #19246 'Rebuilding the loaded feature index much slower in Ruby 3.1'</a></p> Ruby master - Bug #19378: Windows: Use less syscalls for faster require of big gemshttps://bugs.ruby-lang.org/issues/19378?journal_id=1020972023-03-01T22:12:24ZMSP-Greg (Greg L)
<ul></ul><p>Just to be clear, this issue affects all Windows MRI platforms, so both mswin64 and mingw32 (mingw & ucrt builds) are affected.</p>