Hello,
I am trying to speedup the ruby1.8.6 ‘require’ function for Windows.
I’ve noticed that for file that successfully found FileMon reports too
many such errors:
DeviceIoControl, FAST IO DISALLOWED, Control: 0x12043
DeviceIoControl, INVALID PARAMETER, Control: 0x12043
One of the sources of these messages is:
win32.c > rb_w32_fclose > is_socket > getsockopt
I decided to reproduce this error. So, I wrote a test application linked
with msvcr80-ruby18-static.lib:
FILE * fp = fopen(fname, “r”);
fclose(fp); // This results in rb_w32_fclose call.
But I do NOT get DeviceIoControl errors from my_test!
So in short
- I get DeviceIoControl errors from rb_w32_fclose called by ruby.exe
- I do NOT get DeviceIoControl from rb_w32_fclose called by my_test.exe
- Errors come from the ‘getsockopt’ function.
Can any one explain this, please? How can we avoid errors comming from
ruby.exe?
Thank you,
Aha… I forgot to call WSAStartup. No my_test.exe reports
DeviceIoControl errors too.
Btw, is not there any better alternative for ‘win32.c > is_socket’
function?
My reply is over there in Usenet, apparently the attachment was too
large:
http://groups.google.com/group/comp.lang.ruby/msg/8f85de91d3c3ba77
Cheers
robert
Hello, Robert
Your logs looks good.
I tested again in such environment:
OS: Vista
Process Monitor: 2.03
Ruby: 1.8.6, 1.8.7, 1.9.0
Used the same a.rb and command line as you. I got similar results for
all ruby versions: every successfull read of a.rb is followed by ~60
DeviceIoControl.
I can’t attach my CVS (posting from google site). How did you attach
it?
Hi, Robert
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Probably cygwin is not calling the same OS functions.
Maybe it’s in your environment? Do you somehow require “rubygems”?
I tested on Windows Server 2003. And I tryed with/without rubygems -
same results.
Btw, I compiled ruby from sources, and changed rb_w32_fclose.
//if (!is_socket(sock)) {
if(1) {
…
return fclose(fp);
}
The DeviceIoControl lines are gone. Then I checked the speed. I
installed rails 2.2.2, then did:
- irb -rubygems
- s = Time.now; require ‘activesupport’; e = Time.now; e.to_f - s.to_f
For normal ruby results was:
~ 1.16 sec
For patched ruby:
~ 1.00 sec
Not a big advantage, but any way. Going to see if in more complex
situations this can be more valuable…
On 15.12.2008 02:20, [email protected] wrote:
Hello, Robert
Your logs looks good.
And I also do not notice any slowdowns of require.
I tested again in such environment:
OS: Vista
Process Monitor: 2.03
Ruby: 1.8.6, 1.8.7, 1.9.0
My version was
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Used the same a.rb and command line as you. I got similar results for
all ruby versions: every successfull read of a.rb is followed by ~60
DeviceIoControl.
Maybe it’s in your environment? Do you somehow require “rubygems”?
I can’t attach my CVS (posting from google site). How did you attach
it?
I sent it via Newsreader to the newsgroup comp.lang.ruby.
Kind regards
robert
2008/12/17 Alex 2k8 [email protected]:
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Probably cygwin is not calling the same OS functions.
Yes, that’s a likely explanation.
For normal ruby results was:
~ 1.16 sec
For patched ruby:
~ 1.00 sec
Not a big advantage, but any way. Going to see if in more complex
situations this can be more valuable…
I don’t think it’s worth the hassle. Just my 0.02EUR…
Kind regards
robert
On Dec 17, 4:26 am, Alex 2k8 [email protected] wrote:
Hi, Robert
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Probably cygwin is not calling the same OS functions.
Maybe it’s in your environment? Do you somehow require “rubygems”?
I tested on Windows Server 2003. And I tryed with/without rubygems -
same results.
I see the same issue here, with MSVC builds. However, with MingW
builds, i don’t get the problem. The is_socket function you mention
has been changed significantly in 1.9.1 anyway.
For normal ruby results was:
~ 1.16 sec
For patched ruby:
~ 1.00 sec
Not a big advantage, but any way. Going to see if in more complex
situations this can be more valuable…
Submit a patch to core 
-=R
Submit a patch to core 
This was not a patch, just an experiment. I simply commented a call to
is_socket in rb_w32_fclose function. The ‘require’ works, but socket
related functionality whould be broken
And as for now I see no
significant improvements, not going to continue.