Jonathan Barnes's blog



Standup 08/21/2008

edit Posted by Jonathan Barnes on Thursday August 21, 2008 at 04:57PM

Interesting Things

  • APIdock.com is a web app that provides a rich and usable interface for searching, perusing and improving the documentation of projects that are included in the app.

Standup 08/20/2008

edit Posted by Jonathan Barnes on Wednesday August 20, 2008 at 04:36PM

Ask for Help

"We are getting 504 Gateway errors and we thing it is because our mongrels are freezing up do to inability to allocate memory, what to do?"

Without more info on the problem a few possibilities were suggested, such as the OS might be swap thrashing or the OS has no more memory to allocate.

One suggestion is to cut down your swap space to 0 in an attempt to verify that your mongrels are asking for too much, basically remove to OS swapping memory to disk from the equation.

Another suggestion is to boost your swap up to some insane size, also to take it out of the equation, the theory being that we know mongrel can leak memory, we trust the OS to keep the used memory in RAM, and we have plenty of disk space, so why put your OS in the position of not grating a mongrel what it is asking for.

Both solutions above don't seem ideal but, whatever, we are pragmatists, and if we combine those with periodic monitoring of the system using top/ps/vmstat, at least your mongrel can keep running and this may give you time to figure out why mongrel may be so memory hungry

Standup 08/19/2008

edit Posted by Jonathan Barnes on Tuesday August 19, 2008 at 04:25PM

Interesting Things

  • If your wanting better out-of-the-box error messaging you can use one or both of the following plugins:
    • active_record_full_messages_should_be_nicer
    • validates_associated_displaying_associated_errors

If you choose to use both however ORDER DOES MATTER (use the order specified above) otherwise the validates_associated one just doesn't seem to work.

  • Hash Iterations is very expensive (this includes my_hash.keys and my_hash.to_a etc...). We think this is related to the way hashes are stored in large, sparsely populated hashtables. If you can, avoid iterating over a hash, and if you must, try using a SequencedHash (which is provided by the collections gem) which solves this by storing hashes as both traditional hashtables and arrays, allowing for fast random access (the hashtable) as well as fast iteration (the array).

Ask for Help

"We want to load a different set of libraries for our selenium test than our regular tests. We tried to create a 'selenium' environment and pass that to the rake:test task but that didn't work, anyone know why?"

You cannot run in non 'test' environment with the rake tasks as the 'test' environment is hard coded into the test task, and passing a different RAILS_ENV seems to only have the effect of telling the 'test' environment what database to base it's schema off of.

Proposed work around - pass a second environment variable e.g. selenium=true and switch on that. (it's not ideal so we are still open to better solutions)