[Win32utils-devel] Some more win32-changenotify analysis

Daniel Berger djberg96 at gmail.com
Wed Aug 8 07:05:00 EDT 2007


Hi all,

I decided to check the responsiveness of the pure Ruby vs C extension 
versions of win32-changenotify. I setup this little file generator program:

a = []

10.times{ |n|
    a << Thread.new{
       File.open("File_#{n}", 'w'){ |fh| fh.puts "test #{n}" }
    }
}

a.each{ |t| t.join }

The pure Ruby version did not do so well. In some cases it only picked 
up one event. In most cases, it didn't pick up *any* events!

The C extension did much better, though the behavior was somewhat odd. 
Most of the time it picked up multiple notifications on some files, 
while missing others entirely:

[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_0">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_4">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_4">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_5">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_5">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_6">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_6">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_7">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_7">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_8">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_8">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_9">]
[#<struct Struct::ChangeNotifyStruct action="modified", 
file_name="test1\\test2\\File_9">]

I also tried with a C version of win32-changenotify using a pure Ruby 
version of win32-ipc. Although the results were mixed, it did seem to 
get a little worse in terms of the notifications it returned, typically 
only returning 4 or 5 notifications, though sometimes it did as well or 
better than using the C version of win32-ipc, so I'm not sure what to 
make of that.

I'm not sure what to make of the fact that the pure Ruby version doesn't 
pick up Threaded events most (all?) of the time. Maybe there's some way 
to use threads within changenotify.rb to make it more responsive?

Otherwise, I think I'll have to declare this a failed experiment.

Regards,

Dan


More information about the win32utils-devel mailing list