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
1. I get DeviceIoControl errors from rb_w32_fclose called by ruby.exe
2. I do NOT get DeviceIoControl from rb_w32_fclose called by my_test.exe
3. Errors come from the 'getsockopt' function.
Can any one explain this, please? How can we avoid errors comming from
ruby.exe?
Thank you,
- Alex
--
Posted via http://www.ruby-forum.com/.
Btw, is not there any better alternative for 'win32.c > is_socket'
function?
I did this with cygwin's version of Ruby
$ ruby -r a -e '1'
There was an empty file a.rb in the current directory.
I used Process Monitor 2.03 which is the successor of File Mon. I
exported the trace filtered for the file name in field "Path" and
"Process Name" for "ruby.exe". Please find the result attached. I did
not find any DeviceIoControl which might be because of the other ruby
version.
HTH
Cheers
robert
http://groups.google.com/group/comp.lang.ruby/msg/8f85de91d3c3ba77
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
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?
- Alex
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
> 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:
1. irb -rubygems
2. 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...
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
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.
Submit a patch to core :)
-=R
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.