Posts Tagged ‘ruby’

Doing battle with metric_fu

August 8th, 2010 by Brian | 2 Comments | Filed in work

Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Churn, RailsBestPractices, Subversion, Git, and Rails built-in stats task to create a series of reports. It’s designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.”

It’s really a pretty sweet tool. It generates all these reports and you can either ignore them or act on them. Not saying which of those we do… but that’s not important right now.

If you’ve used metric_fu you probably ran into the NaN error. Good ol’ “Not A Number”.
Generally the output looks something like this:

NaN
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/float/rounding.rb:19:in `round_without_precision’
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/float/rounding.rb:19:in `
round
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:135:in `round_to_tenths’

/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/generators/rcov.rb:85:in `to_h’
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:131:in `
generate_report
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:53:in `generate_report’

/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/report.rb:54:in `add’
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6:in `
each
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6

This particular error has cropped up several times for us, each time we do the same google searches, look at the same metric_fu sources, and slowly dissect which tests are causing this problem. Hopefully this post will help expedite debugging this error for you and your friends.

(more…)

Tags: ,

Compleat Rubyist – Day 1

June 19th, 2010 by Brian | No Comments | Filed in work

Day 1 of 2 of my notes for the Compleat Rubyist training course

Ruby Versions and Implementations  – David

http://ruby-versions.net/ – David’s home for ruby versions & implementations for learning & historical reference

Ruby version manager – http://rvm.beginrescueend.com – lets you install several ruby versions/implementations and easily switch between (including your own custom compiled version). Suggestion – don’t install as root, even though it is allowed.

Notes on a few of the existing options:

  • MacRuby – interacts with Cocoa
  • Rubinius – Ruby in Ruby
  • JRuby – Ruby on JVM
  • REE – optimized – created by Phusion Passenger team
  • MagLev – built in object persistence, repository instead of files, smalltalk-ish
  • IronRuby – Ruby on .NET
  • URABE – ?

rvm allows you to compare performance between versions/implementation:

rvm ruby-1.8.6,ruby1.9.2 benchmark filename.rb

Why does everyone use 1.8 instead of 1.9?

  • Same amount of people are using it as last year (like almost no one)
  • Rails considerations
  • 1.9 is not 100% backwards compatible
  • 1.8.7 backported many of the features of 1.9, so people feel safer

Ruby Enterprise Edition has major memory and speed improvements

Highlights of changes between 1.8 & 1.9

  • Enumerators
  • Method parameters
  • Block variable binding & scope
  • Syntax changes

(more…)

Tags: , ,

Make it faster

March 1st, 2010 by Brian | 3 Comments | Filed in work

This past week or so I’ve been concentrating on improving the performance of our system. Thankfully this isn’t a solo task and my teammate really knows what he’s doing. Luckily I was able to contribute based on my past experiences with things like cache settings in Apache, ulimit settings and other tweaks here and there.Make it fast like Pole Postion fast!

We’ve uncovered a slew of things to work on. The first obvious place was to have the static content served by Apache rather than the mongrels. This has been on the todo-list for a long time, but has always fallen to the wayside. We knocked that off and looked towards the other items that were slowing us down. That’s when I uncovered some TCPSocket weirdness within memcache-client 1.7.4 that comes with activesupport 2.3.5.

During some tests we noticed a severe lag which we narrowed down to the fact that we were pointing to a list of memcached servers that contained one that didn’t exist. Turns out that when the memcached hostname resolves, but is not pingable, memcache-client 1.7.4 waits 3 seconds before responding with an error message (in addition it doesn’t mark the server as “down”, which I think is also a bug). This 3 second delay happens on RHEL 4, and in some brief tests on Ubuntu 10.9, it was even worse, taking over 30 seconds to respond. My guess is that there is some OS level setting that affects this, but I have yet to locate it. The fun part however, is that this problem does not exist in our old environment where we run acivesupport 2.1.2 which uses memcache-client 1.5.0.

Turns out, in 1.5.0, the memcache-client uses a 250ms timeout when calling TCPSocket.new. Something that was lost on the way to 1.7.4. Some initial tests of simply adding this CONNECT_TIMEOUT back in have been promising. It’s currently not throwing the right exception or marking the server as “down”, but once I do that, I will see about posting the source somewhere.

Tags: , ,