Sunday, January 10, 2010

FOSDEM 2010

So Ruben has been working on getting a bunch of talks organised for the Mono room in FOSDEM and I've been lucky enough to get a slot. I have a 30 minute slot, so I figured that would be long enough to talk about 2 things properly and then take questions.

I've decided that I want to talk about two things.

  1. The piece picker algorithm
  2. How i handle threading
The piece picking code handles which segment of the file will be downloaded next. It has gone through several iterations, each time adding new features. Eventaully the whole class became so hard to maintain and test that I just had to rewrite things from the ground up using a new approach. This might give some people ideas on how to tackle problems in their own projects but even if it doesn't, it should still be interesting ;)

MonoTorrent handles a lot of concurrent connections. Using one thread per connection just wouldn't scale yet using plain asynchronous sockets and locking has huge potential for deadlocks and race conditions. Getting this right took well over a year - probably due to my lack of experience at this - but right now I think I've hit the winning threading solution. This part of the talk should be useful to anyone who's worked on an app which does a lot of socket operations. Maybe I'll wake up in a few months time and see a dozen apps using that technique.

Anyway, feel free to drop in for my talk (and all the others!). If you have any questions about any other aspects of MonoTorrent, or programming in general, feel free to find me and ask.

6 comments:

Tommy Carlier said...

I liked your talk at FOSDEM. It was very interesting. I liked your "1 thread"-approach. I think you might be able to remove the lock on the queue by using the (lock-free) ConcurrentQueue from the ParallelFx project.

Wim Coenen said...

I enjoyed your short talk. The "lessons learned" on threading resonated with me because I had just run into a deadlock issue in my own code a few days before.

Volker from Germany said...

Hallo,
Ich haben eben Eure Internetseite besucht und nutzen sogleich die Gelegenheit,euch auch einen Gruß aus Deutschland in Eurem Gästebuch zu hinterlassen. P.S. Kommt uns doch auch mal besuchen
http://www.MeerblickSylt.de
http://www.OstseeblickHolm.de

Send Flowers to Canada said...

Hey great stuff, thank you for sharing this useful information and i will let know my friends as well.

site said...

In my opinion everyone must look at it.

aliyaa said...

You can now download free apps and can learn free online learning with perfect planning. this is become so easy and reliable.

Hit Counter