Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

regexp master!

Last week we upgraded a LJ DB which was our bottleneck, and CPU on all our web nodes became the bottleneck. The other day, I made a bunch of easy fixes to speed up the site by cutting CPU usage while new web nodes were ordered/delivered. That pretty much solved the problem, but I've been on an optimization kick ever since.

I spent an inordinate amount of time this weekend rewriting BML's parser for speed.

A half dozen rewrites later, after squeezing out 3% more performance, then 6%, then 12%, then 24%, it's now ~44% faster, and I'm calling it quits. I wasted enough time already.

perldoc perlre is awesome. I'd never read it all word for word until yesterday, and I now feel so enlightened with things like independent matches (?>...) and negative look-ahead assertions (?!...). Not to mention (??{ code }). I look forward to Perl6 Rules.

Anyway, check out this monstrocity:

http://cvs.danga.com/browse.cgi/bml/lib/Apache/BML.pm?rev=1.40

Search for "sub bml_decode" and revel in its power.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 15 comments