Thursday, February 25, 2010

HaskellTorrent v0.0 and further developments

HaskellTorrent v0.0 released!

Last weekend I released version 0.0 of the HaskellTorrent project. However, as modern development will have it, the interesting things happen on the main integration branch, master, on github: haskell-torrent. From the point where the 0.0 release was done and till today, three main things happened in the client.

CPU optimizations

A little bit of work with the profiler has shaved the use of the CPU down by a fairly large amount. I optimized the assertions on the piece database by using Data.IntSet rather than plain old lists. Right now the cost centres are the piece database assertions (still) and deciding which blocks to download. The former of these is simple to get rid of. We don’t need to assert the database at each message, but can do so with a rarer frequency. As for the latter, I have a couple of ideas to shave off CPU cycles on that one as well.

Listen sockets

HaskellTorrent now accepts incoming connections! It does this on port 1579 that has no special connotation apart from being one of the fairly low prime numbers. The etorrent project uses 1729 which has a more interesting history associated with it. Of course, one has to open the eventual NAT/PAT or Firewall to get connections flowing in, should you want to test it.

test-framework

Finally, we now use the excellent test-framework by Max Bolingbroke. The test inclusion was inspired a lot by Eric Koweys blog post on the subject, and it also used bits and pieces from Real World Haskell.

The bottom line is that now you can execute tests directly:

jlouis@illithid:~/Projects/haskell-torrent$ make test
runghc Setup.lhs build
Preprocessing executables for HaskellTorrent-0.0...
Building HaskellTorrent-0.0...
runghc Setup.lhs test
Test test-framework:
reverse-reverse/id: [OK, passed 100 tests]
Protocol/BCode:
QC encode-decode/id: [OK, passed 100 tests]
HUnit encode-decode/id: [OK]
Protocol/Wire:
Piece (-1) 1 ""
QC encode-decode/id: [Failed]
Falsifiable with seed 2776559770653812966, after 1 tests. Reason: Falsifiable

       Properties  Test Cases  Total
Passed  2           1           3
Failed  1           0           1
Total   3           1           4

though it does seem we need to do some work in order to correct the software :)

Post a Comment

About Me

My Photo
Lambda-loving CS Geek. Likes metal music. Likes dogs. Likes cats. Does not like pictures of dogs and cats (unless they are lambdacats!)

Has an unhealthy coffee addiction. Calls himself the coffee zombie in the morning (BEEEEANS!)

Has a neverending curiosity gene. Likes intelligence.