Unbelievably naive mistake, or politically motivated lies? You be the judge.
I have already spent way too much time talking about this piece of garbage, so I am putting up a little persistent comment about it.
This so-called "benchmark" is nothing more than an insult. Yes, he has graphs: but these graphs are not actually measuring anything. It claims to be performance metrics on an MDI application doing image transformations.
The advocacy position which he is so anxious to misinterpret is this: Twisted is an alternative to threads for multiplexed I/O. Many, many applications multiplex I/O, and they do it in a variety of ways which are inefficient and bug-prone, the most popular (and most dangerous) approach being thread-per-connection. There is an explanation of the problem (as well as a link to Twisted) at threading.2038bug.com.
He accuses Twisted developers of letting emotions get in the way. Am I emotional about this? Yes, I am. I am angry about it for good reason. The Twisted team has spent almost a hundred man-years of effort producing something that we could be proud of, to provide our users with a better, more test-friendly, less error-prone way of programming. It's not a new idea, but I like to think we've brought something useful to the table by providing an integrated platform that supports it.
I don't think that my efforts, or those of my colleagues, deserve to be misrepresented in this way. I am upset and writing about this because I am afraid that programmers who don't know any better will see graphs and think that he's proposing a legitimate approach to solve some problem, and I will one day be called upon to help them with their code. Code which will, thanks to "benchmarks" like this one, inevitably, perform extremely poorly and be a total mess of race conditions. I am trying to improve the state of the art in the industry, and it is a lot of work. Widespread circulation of an afternoon's dalliance with a plotting program like the above can undo years of work trying to educate people.
I thought that I would write some benchmarks where the graphs went in the other direction, but the internet is already brimming with graphs that demonstrate the superior scalability of multiplexing with events rather than threads. Dignifying this sophomoric potshot with actual data would be a lot more than it deserves. If you are truly skeptical, I would recommend attending Itamar Shtull-Trauring's Twisted talk at PyCon 2005, "Fast Networking with Python". This will give you a much clearer view of Twisted's current performance problems than the graphs drawn by some script-kiddie who has a grudge because he got banned from an IRC channel for spreading lies.
Just as refuting the numbers would be a waste of effort, refuting every one of the lies and/or misunderstandings in each paragraph could take all day. Instead, I'll just debunk a sample of the most egregious stuff, and hopefully the pattern won't be too hard to extrapolate, for those of you unfamiliar with the subject matter.
Threads will work on multiprocessor and hyperthreading machines automatically. On similar hardware Twisted will use only 1/n of the available processing power, where n is the number or virtual or physicial [sic] processors.
What he means is, python will only use 1/n of the available processing power. For code that actually makes use of SMP, you need to relinquish the global interpreter lock, and write all parallelized code in C. This is thanks to the global interpreter lock, a problem which is hard to solve, since making Python multi-CPU friendly actually makes it slower. Note - you don't need to do anything special to take advantage of SMP if you use Twisted's recommended, non-threaded way of parallelizing things, which is spawning multiple worker subprocesses.
So, Twisted can use exactly as much processing power as Python, especially because Twisted supports threads.
Twisted people think you should spawn a separate process for intensive work. If you do this you need to synchronize resource access as you would with threads. That is probably the most mentioned problem with threads.
You don't need to synchronize resource access when you use subprocesses. You can copy data to multiple subprocesses and serialize resource access, without doing any extra work, since Twisted will deliver attempts at resource access through normal I/O delivery channels, which are processed by the main-loop. Also, you can run your subprocesses in isolation, without concern for synchronized access to shared data structures. In the case which he seems to be talking about, e.g. that of large shared memory objects which need to be mutated and then operated upon by multiple cooperating processes, you can still avoid locking by using a tuple-space model of interaction and delivering work to subprocesses through pipes rather than delivering data. This still only has one simple program managing the interactions of many, taking advantage of the OS's much-vaunted thread-switching abilities, and doesn't require mutexes on every operation.
You also need to find an effective portable method of inter-process communication. This is not much of a problem, but it is something you wouldn't have to do with threads.
You certainly have to do this with threads. It might appear as though you do not, and in some cases it may be slightly easier to implement, but if you don't track which objects are in use by which threads, mutex overhead will quickly cripple any performance gains that you'd see in a threaded application. So your IPC mechanism with threads is queues, or condition variables, rather than pipes or shared memory, but it's still there and it still requires a lot of maintenance.
In conclusion, I stand by one of arensito's last claims:
When I approached Twisted people with questions about these results I was told I was not worth listening to. Followers stated bluntly they were smarter than me.
In fact, he isn't worth listening to, and I am proud to say that the Twisted team is smarter than he is. More than that: he's worth not listening to. The "benchmark" that he has proposed does not test anything about Twisted, and does not test anything meaningful about his hypothesis.
There's lots of work to be done on Twisted, and it certainly has its share of performance problems. It's by no means the fastest system of its kind. I am always excited to hear about ways it can be improved, but don't just make up a bunch of lies, write a while loop, slap a graph on it, and claim you've discovered something better.
Migration Report
20 hours ago
9 comments:
It sounds like he tried to bring this up on IRC, and didn't get anywhere. Maybe he was rude or stubborn, I don't know -- the social dynamics of IRC seem to generally suck, IMHO, and misunderstandings abound in those forums.
Instead of attacking him (I mean geez, "politically motivated lies"?), have you tried making constructive critiques of the specific code, benchmarks, or criteria he is using? Do you have a measured rebuttal that doesn't resort to ad hominum attacks that you've asked him to link to in his document? Have you asked him to clarify some of his points, or provide a more measured response? Frankly his document comes off as the more reasonable one, expressing some frustration with the response he's received, but it doesn't come off as a wholesale condemnation of Twisted.
And are people not allowed to defend threading? Are people not allowed to critique Twisted? Are you only allowed to critique Java and Zope and threads? Because this response isn't a I-think-he's-wrong kind of response, it's a I-think-he's-wrong-for-even-saying-this kind of response, and there's a big difference in the civility of the debate.
Ian, I should add that you have quite a bit more clout than this fellow, and if you feel that there is actually a substantial criticism underneath this crap, that could be expressed in a more productive way, I would love to hear it.
Also, I would not mind hearing directly from developers who, as arensito claims, have wasted three months working with Twisted. There is a lot of documentation out there, and many forums where you can get help - if he's telling the truth it *is* outrageous that so much time could be lost. But, since the actual problem was not presented, and those developers have not come foreward with a description of what advice mislead them, I cannot respond to it or do anything productive or useful in response.
Good rant, I liked it. But I recommend you alter the link to his document to have a rel="nofollow" otherwise you're just increasing his googlerank.
http://www.livejournal.com/users/puzzlement/51155.html
Honestly I don't really care about the kind of scaling he's talking about, and the graphs look funny to me -- that Twisted jumps around just makes me think there's something odd about the test, I wouldn't infer any general scaling issue. In the conclusions he really only seems to claim that Twisted doesn't scale any better than threads; and given certain criteria (e.g., performance or response time), this seems true, and not very surprising. I do think threads are often unfairly maligned, so from that perspective his critique seems reasonable. But I don't have anything against Twisted; I think it would actually be my prefered threaded backend for WSGIKit (the only issue being the size of the install -- a smaller base Twisted install would be really helpful there).
But really I was just concerned about the form of the response, especially when there was just another similar fight over benchmarks. From what you say, it sounds like he has a chip on his shoulder. But then something about IRC leads to this kind of polarization. Bringing the discussion out of that forum there's an opportunity to be less antogonistic, to turn the other cheek at what you consider a personal slight (since you personally have so much invested in the project) and move forward or just move on. If he's just a troll, you'll ruin the fun of it and take the winds out of the sails of his indignation. (OK, way way too many metaphors, sorry). If he's not a troll you might help to resolve a technical disagreement, either clarifying your actual claims regarding Twisted, or clarifying the actual meaning of his numbers. And either way it's easier than feeling angry about it.
... but is 20% of speed so important?
If you like Twisted, no reason to mention it;
If you like threads, why the efforts to test Twisted?
Nobody can test a software with ~50k SLOCs without deep understanding and long practical experience with it, especially if it is a "framework for frameworks".
There are lot of Python packages, which deserves big respect, and Twisted belongs to the top in my eyes - not because it is 20% faster than XY or Z, but because it is covering extremely large area of solutions, clearly structured and easy usable. It is the best Python tutorial, I've found.
FWIW, the Twisted 2.0 release is all about splitting twisted up into smaller bits. We have known it should be done for years now, and it's just taking a while because everyone working on it is doing it in spare time, and there is not too much of that at the moment.
So, you can install twisted.base and twisted.web without installing a mail server, dns server, ftp, async db pool, irc code, rpc mechanism (pb) and various half-finished databases.
a smaller base Twisted install would be really helpful there
Good thing we're splitting it up, then :).
I was just concerned about the form of the response, especially when there was just another similar fight over benchmarks.
I might not have chosen an optimal form for the response, and I probably could have been calmer about it. Still, I am tired of giving equal respect to trolls and agitators who are using feigned "reasonableness" as a shield, as to people who are actually reasonable and trying to make a serious contribution.
This guy showed up in #pygame today ranting about Java and "science" and "logic". I feel for you.
I'm sorry for you. Don't feel too bad for me though - he's banned from all the IRC channels that I frequent now :).
Post a Comment