Sunday, December 27, 2009

Speeding up firewatir

My recent work is pure ajax single-page application. And now I'm trying to cover it with some tests. Yes, I'm not TDD-infected, but that's a story for another post. And I've tried Firewatir. I quickly encountered it's known issue of being slow sometimes.

After a bit of investigation it turned out to be lack of TCP_NODELAY on both sides of firefox control socket. It's surprisingly typical that programmers are not aware that Naggle's algorithm affects localhost-to-localhost sockets too. In this case short requests and responses were unnecessarily delayed in kernel because of that.

The most interesting thing was fixing this issue. It seems that (re)building JSSh extension that is firefox side of Firewatir power is not very convenient and quick process. So I made a funny hack instead.

In one of my earlier posts I described a piece of code that drives GDB from ruby to get backtrace from running ruby process. This time I decided to use same approach to set TCP_NODELAY on connected socket inside running firefox process. I extended old code and published it at http://github.com/alk/alk-ruby-gdb-hacks/blob/master/gdb.rb. After creating Firewatir instance you simply need to call
GDB.force_socket_nodelay($jssh_socket)


No comments:

Post a Comment