Sunday 5 September 2010

Beyond Either/Or

So I was doing a massive file comparison operation (hundreds of thousands of files, >100 GB of data) today on one of my Windows boxes and so naturally fired up the excellent WinMerge, my favorite — by a wide margin — Windows-based visual diff/merge tool. And it did something that is so smart, I just had to mention it.

Usually when you ask software to do an operation on a set of files you identify by wildcard or what-have-you, the software does one of two things: It either goes off and finds all of the files first, and then starts processing them; or it just starts processing and discovers the files as it goes. The former is useful for progress bars, for an early indication that maybe you've messed up your filters, etc.; and the latter is useful for those "I don't care how many there are, just get on with it!" situations.

So what was the smart thing the developers of WinMerge did? They did both. One thread went off to discover files, and another thread got on with the business of doing the comparison for me. It was exactly what I didn't know I wanted.

Are there trade-offs to this approach? Probably. You'll be asking the devices you're reading from to do two things at the same time for a while (list files and read files), which could impact overall performance. Or not, it depends a lot on what the devices are — do they have thrashing issues, are you maxing out your channel to them or does your post-receipt processing take most of the time, etc., etc. In my case, I was dealing with HDDs which presumably did have to thrash a bit (or a lot) early on, but for me it was still a really useful user experience.

So the point is, as it frequently is, to remember ask whether "both and" is an option when looking at an either/or choice. (One of probably three questions you should automatically ask when faced with such a thing, the other two being "is 'neither' an option?" and "are there more options?")

Or maybe the point is just to say "nice one" to the WinMerge devs. Either way.

Happy coding. -- T.J. ;-)

1 comment:

Angel17 said...

Wow! That's very awesome. It's great that it can do that multi-function. Thanks for sharing! Wake Forest NC Tree Service