mikel/mail — pull request #505 by ConradIrwin (2013-02-02 07:50:35+00:00)
Title: Performance improvements for people parsing email headers

The main change here is to defer as much header-parsing work as possible. This gives me a 2000x speedup for an (admittedly pathological, but real) example when combined with Pull #490

This email was sent around our company: https://gist.github.com/5901bbd810c08ed3d0b1, master currently takes `6.9s` to parse those headers!

Pathological example:

master: 6.9s
bpot/ragel: 0.3s
lazy-fields: 0.008s
lazy-fields + bpot/ragel: 0.003s

(The "best case" would be as fast as my hacky `zippy_from` function, which is 0.0005s so still 7 times faster than I managed to make this. Most of the remaining time is spent in `.to_crlf` and `.split`, see [profiler output](http://jelzo.com/stuff/lazy-fields+bpot-ragel.pdf), so I'm pretty content to leave it as-is)

rspec on ruby-1.9.3:

master: 19s
bpot/ragel: 5.6s
lazy-fields: 11s
lazy-fields + bpot/ragel: 4.2s

(Other rubies had similar shapes, but different actual numbers)