[Libbt-devel] News on the Mac front - LibBT 1.03
Brought to you by:
ksmathers
From: Dakidd <da...@so...> - 2005-05-11 16:04:39
|
As of about an hour ago ago, I've got an error and warning free compile, and functionality of both btcheck.c and btlist.c on a PowerMac 7500 hopped up to a G4@350 running MacOS 9.1. Testing has been done using locally-stored .torrent files that I've actually used for live transfers using the "official" Python implementation of BitTorrent (note 1) in sizes ranging from a couple hundred K to a couple-few-hundred megs, both single-file and "directory" modes. I'm pleased to report that, with the exception of a cosmetic glitch (Looks like an "LL" suffix is being used, rather than an "L") in a printf format string (From the debugger, I can see that the correct data is in the variable, it's just getting printed wonky), execution has been flawless. And speedy! As an example, hashing torrent pieces - I have a fileset (.torrent and target file - Target file size just a shade over 175 megs) that takes well over an hour and a half to hash and decide whether it is or isn't complete when using the "Official" Python-based client. The same file going through btCheck (which I'm building to use a slightly adapted public domain SHA1 implementation called "ReidSHA", since OpenSSL hasn't been ported to Classic MacOS (note 2) that I know of) is hashed and verified as complete or not after only 51 seconds! That's with *ZERO* optimizations being applied - No "hand-crafting ML byte-strings", no compiler optimizations or use of special processor features, just a straight-up "as it is written, so shall it be compiled". Once I decide to crank up the compiler's brainpower by turning on some of the compile optimizations, I expect the speed will improve even more as it starts sequencing and pipelining the generated code and making use of currently unused processor features like predictive branching or the G4's "Velocity Engine"... But I digress... The LibBT 1.03 tarball was my base code, and despite my bitching about Kevin's coding *STYLE*, I have to be fair and say that I can find nothing to bitch about in his *CODE* once it's been hammered into readability. A couple of gaffes here and there, which is only to be expected in a project like this, where the spec is a moving target, and the codebase is evolving to hit it, but overall, nice and tight. It's just that the voyage to readability can be frustrating! But, once it gets there, it's a sweet codebase, with a lot of headroom, and pretty much ALL the toys that should be needed to follow the protocol wherever it goes. And if it comes up short? Well, that's the beauty of open source... SOMEBODY will get miffed at the lack, and fix it! A million monkeys, with a million keyboards, typing for a million years, just might up and (re)write Linux, too! Or worse... Windows!!! AUGH!!!! Start shooting monkeys - QUICK! :) Next step: Hacking the bejeezus out of the stuff that tries to talk to the 'net. CURL - FLUSH! Gonna use Apple URLAccess instead. That'll get me talking to the tracker. Then it's on to try to change from *nix/Windows style networking using the nice, simple, freindly, reliable, Sockets TCP/IP API, to Mac's god-awful train-wreck of a TCP/IP implementation called "OpenTransport" so that my servent can talk to others. If I'm not back in 6 months, call the mounties and tell 'em I went thattaway! And tell 'em to bring extra rope - I'll probably be be found clinging to a knot tied at the end of mine! :) BTW: Update, since I see I bailed out of Eudora before it could actually post this message - It's now several hours later, and the glitch in the printf (turned out to be exactly what I thought it was: LL in a format string instead of L) has been fixed. Operation and functionality of both btCheck.c and btList.c are now 100% with all torrent files I've thrown at them (about 40, all of them previously used to control actual transfers) so far. Making copies and moving them around, then mangling the target data of the torrent in some way to simulate damaged/missing pieces has been detected and reported as present down to the single changed bit level, so the "Something's wrong with the file" mode is working just as well as the "Yep, the file's all there" functionality. I'm officially declaring this portion of the port to Classic MacOS a success! Now to get the networking to happen so I can build a client using a REAL language instead of being stuck with that godforsaken Python interpreter. Interpreter... <snork> I'd rather compile it! :) <Ponders Applesoft (Apple IIe BASIC) or Apple Integer BASIC on a Mac> <flees, screaming for tranquilizers, at the thought> Anyway... I *THINK* I've managed to conditionalize my changes in such a way that Windows/*nix folks can compile my changed code by simply substituting their own config.h file with the last line before the final #endif reading "#define TARGET_MACOS 0" or "#undef TARGET_MACOS". My intent was to be sure that my changes are completely transparent, but I cannot claim with certainty that I've managed it. (note 1) Painfully slow, written in an interpreted language (Python) whose only available (to my knowledge) Mac-hosted interpreter keeps crashing on me. Python is also a language which bears the second curse of being "foreign" to me - I don't grok Python (and to be blunt, I don't WANT to grok Python - it makes my brain itch) so I can't fiddle with it to try to make it faster, despite having the source code staring me in the face. Hence, my motivation to get a C-based BitTorrent "toolkit" operational on the Mac. To make things worse, the interpreter has its own bugs and glitches, so that about half the time, I wonder whether the most recent problem I've encountered has been with BitTorrent or a problem with Python. (note 2) For you non-Mac folks, "Classic" distinguishes the older MacOS (9.2.x and below) from "The cats" - MacOS X - AKA 10.x.x AKA Jaguar/Panther/Etc. (I think we're officially up to Tiger now - Or does that release next week? It's either just released, or releasing very soon) MacOS X is based on *nix - a sub-flavor of NetBSD, if I recall rightly - while MacOS 9.x and earlier are now grouped as "Classic", and despite looking pretty similar on the screen, are pretty significantly different than X when you crawl under the hood and start banging the bits directly against the silicon. Don Bruder - da...@so... <--- Preferred Email - unmunged I will choose a path that's clear: I will choose Free Will! - N. Peart |