Thursday, April 30, 2009

Copyrighter v0.4 - Multithreading implemented!

by Hasan Karagülmez
So yeah, there you have it, Copyrighter has got multithreading now! :)

copyrighter v0.4 mainwindow
click for larger image

Download
You don't have to do anything to take advantage, just download the new zip-package HERE (366kB zip-file).

A sample, copyrightimage, xml-file and preview image are included, as well as a small readme text-file.

The executable itself is only 83.5kB, 2.5kB smaller than v0.3 :)

Additional information
Due to the architecture in place, multithreading was a relatively easy affair and I'm also pretty happy with the performance improvements. Testing on my Quad-core 2.4GHz Q6600 processor shows an improvement of around 2 times compared to the v0.3 of Copyrighter.

I've tested this with a batch of 3440 images (!!!), with image-sizes varying from 800x533 pixels (a typical size I use for uploading images to the web) to about 2523x660 pixels, with filesizes varying of 84kB to about 556kB. I get almost 1100 images per minute with Copyrighter v0.4, versus almost 500 images per minute with version 0.3.

Yes, I'm pretty happy with this kind of performance :)

In this version, all the work is done on seperate threads, away from the UI-thread, which keeps the main program also nice and responsive :) Copyrighter v0.3 did all the work on the user-interface (UI) thread (which is why v0.3 hangs when processing), so that's fixed now!

In fact, whilst it is processing, you can just drag-and-drop a new batch of images and they'll be processed as well. I've had it up to 24 simultaneous threads without a problem, processing different batches :)

Threading
Copyrighter v0.4 divides the work over the present (logical) processors in the system. Copryrighter starts with 2 threads (used in the main window), and when images are dropped, the amount of work is divided over the available processors. So, on my quad-core machine, there are 4 logical processors, and so (at most) 4 threads are created which will do the work. Copyrighter will then have 6 threads.

If you've got a dual-core machine, the amount of work will be spread out over 2 additional threads, so Copyrighter will have then have 4 threads.

When you drag-and-drop, that work will again be spread out over the available processors. So, in my quad-core machine, if Copyrighter was at 6 threads, it will then have 10 threads after an additional drag-and-drop.

When all work finishes, Copyrighter will fall back to the default 2 threads.


Final Words
That's it really :)

The working is still the same, so please check the blog-entry regarding v0.3 for extensive information.

Basically, just drag-and-drop images onto the main program-window, images are outputted in a subdirectory called "Processed".

I've always wanted to implement multithreading in Copyrighter and I'm glad I did. I hope this program can help you, let me know what you think - I'd really appreciate it :)

2 comments:

  1. Very usefull and saves a ton of work.
    Thanks !

    ReplyDelete
  2. No problem, and thank you for trying it out! :D

    I'm currently working on supporting texturing in the borders and rounded-borders, so keep your eyes peeled :)

    ReplyDelete