Archive for the 'Programming' Category

Boost Rails performance by generating constants

Thursday, March 11th, 2010

This may be obvious to everyone already, but it was new to me.

Serendeputy hits a few Tokyo Cabinets when it assembles a page. I was having trouble with these sometimes getting hung up, especially when looking up some of the ancillary information. I keep all the tag metadata in the main librarian cabinet. The site looks up this data pretty often. This would manifest itself on the site with a 500 error, and the Passenger Rails process would hang. The site would return 500s until I restarted the process. Ugh.

So, I did a couple of things (which I’ll likely talk about later.) The easiest one was probably the simplest.

I ended up adjusting the librarian build to not only populate the appropriate cabinet, but to also generate a ruby source code file in which I declared a constant with the tag metadata hash defined. I then restart Passenger to pick up the new constant.

Now, Rails only loads this once, and it’s in memory for the rest of the time. This not only saves me the network latency, it makes the individual responses much faster.

It’s always fun to solve complex problems with simple brute-force actions.

Make everything as simple as possible but no simpler

Tuesday, January 26th, 2010

I hope Yahoo BOSS doesn’t go away

Thursday, July 30th, 2009

Workaround for IE7 mouseout bug

Tuesday, June 30th, 2009

Built out the vocabulary engine

Wednesday, June 24th, 2009

Tables in Emacs Org Mode

Friday, May 29th, 2009

How to prevent browsers from caching a page in Rails

Tuesday, April 14th, 2009

Where am I?

Thursday, April 9th, 2009

Getting through the Dip

Monday, February 23rd, 2009

The sublime joy of bug-fixing

Friday, September 26th, 2008

How to reload a class in irb

Tuesday, September 16th, 2008

How to test tag attributes using assert_select

Wednesday, September 10th, 2008

How to get Subversion to ignore your Rails log files

Friday, September 5th, 2008

Revving the prototypes

Monday, August 25th, 2008