Wednesday, October 21, 2009

Thunderbird Slowness

My workstation has 4G of RAM, two 3.2Ghz dual-core Xeons, and a 3Gbps SATA drive with an 8M buffer... which is much more than adequate. However every now and then Thunderbird 2.0.0.23 (20090817) demands 100% of a CPU and hangs it. It even will freeze Gnome to the point that I can't spawn new xterms and I sometimes login on tty1 and kill Thunderbird. I'm just using it for IMAP and SMTP and it does this randomly. Not when I ask it to search for a buried message or while I'm waiting for a large message to be accepted by the SMTP server. I straced it during the slowness and saw:

$ strace -p 12434 2> thun_slow.txt & 
$ tail -f thun_slow.txt
Process 12434 attached - interrupt to quit
lseek(48, 51859456, SEEK_SET)           = 51859456
read(48, "60D]-\n  [-3B60E]-\n  [-3B60F]-\n  ["..., 4096) = 4096
read(48, " [-3B6A0]-\n  [-3B6A1]-\n  [-3B6A2]"..., 4096) = 4096
fstat(48, {st_mode=S_IFREG|0644, st_size=58669928, ...}) = 0
lseek(48, 58667008, SEEK_SET)           = 58667008
read(48, "^96^2E14)(^87=6f3)(^9B=8e27a)(^8E"..., 4096) = 2920
lseek(48, 51863552, SEEK_SET)           = 51863552
read(48, " [-3B6A0]-\n  [-3B6A1]-\n  [-3B6A2]"..., 4096) = 4096
...
To get some stats:
$ wc -l thun_slow.txt 
17160 thun_slow.txt
$ grep read thun_slow.txt | wc -l
9640
$ grep lseek thun_slow.txt | wc -l
5260
$ grep fstat thun_slow.txt | wc -l
1286
$ egrep -v "fstat|read|lseek" thun_slow.txt | wc -l
974
$  
So, it slows down when it decides to read a lot. I have about 1G of mail on the server and 84M in my .mozilla-thunderbird directory. My first thought was that it was indexing, but right-clicking on the folder and asking it to re-index my inbox (with many subdirectories) is very quick. Why does it decide to read a lot (presumably from my disk) at random points during the day?

Update: An article describing similar symptoms suggested corrupt MSF files and suggested stopping thunderbird, backing the profile up, deleting the MSF files and letting thunderbird rebuild them upon restart.

$ tar cvfz thunderbird.tar.gz ~/.mozilla-thunderbird/
$ find ~/.mozilla-thunderbird/0mp6haa5.default -name \*.msf -exec rm {} \;
After restarting Thunderbird it seems zippy enough. The real test will be the non-recurrence the seemingly random sudden spike in read activity.

Update: Two days later and so far so good. I think it might have had trouble reading a corrupt MSF file so it kept trying to read it. The MSF rebuild seems to have done the trick. I'll update again if it comes back.

No comments: