Oct 29, 2007

Rails 2.0 Performance part 1

Recently, being myself, I couldn't resist the urge to try out preview release of Rails 2.0. So be prepared for series of posts about what's new and hot. First thing I've decided to test was performance. I've created an extremely simple rails app - just fetch a row from a database and render its contents - and ran benchmark against single mongrel instance with rails 1.2.5 and 2.0-pr. Results are pretty impressive! Check it out:

Rails 1.2.5:

Concurrency Level: 1
Time taken for tests: 44.663975 seconds
Complete requests: 2000
Failed requests: 0
Write errors: 0
Total transferred: 644000 bytes
HTML transferred: 104000 bytes
Requests per second: 44.78 [#/sec] (mean)
Time per request: 22.332 [ms] (mean)
Time per request: 22.332 [ms] (mean, across all concurrent requests)
Transfer rate: 14.06 [Kbytes/sec] received


Rails 2.0-pr:

Concurrency Level: 1
Time taken for tests: 16.249851 seconds
Complete requests: 2000
Failed requests: 0
Write errors: 0
Total transferred: 1158000 bytes
HTML transferred: 230000 bytes
Requests per second: 123.08 [#/sec] (mean)
Time per request: 8.125 [ms] (mean)
Time per request: 8.125 [ms] (mean, across all concurrent requests)
Transfer rate: 69.54 [Kbytes/sec] received


Pretty impressive, isn't it? Now before you go all crazy about how damn fast Rails 2.0 is keep in mind that:
  • This was a quick test, unverified, vulnerable to many environment variables
  • It was a very simple app, real-life apps are very different in nature and can get very little speed up compared to this test
I just wanted to say that surely a lot of effort was put on performance. I haven't had much time for real tests, but I'll try to find some time within next couple of days to do it the right way and share the results with you.

Oct 26, 2007

Deskbar makes friends with Tomboy

Hi there, again. Recently I've been working on my first deskbar plugin and now is the time to finally give it some freedom!
As you can guess it's a tomboy plugin for deskbar, so you can search your notes in your favorite place.
There's still some work to be done, but it's usable at the current state. For those of you who love screenies here's a sneak peek:


So yes, it does a search by title and tags. It doesn't work with history yet, and won't open your notes if tomboy is not running (it uses dbus).

Get it while it's hot

You can download version 0.1 here. Tested only on Ubuntu 7.10 Gutsy Gibbon.

Installing

There are 2 places you can copy the plugin to. You can copy it to /usr/lib/deskbar-applet/modules-2.20-compatible/ if you want it system-wide (requires root) or to .gnome2/deskbar-applet/modules-2.20-compatible/ in your home directory if you want it just for a single user.

Enjoy

Please leave your wishes/bug reports/whatever as a comment and I'll try to look into it and improve the plugin.

Oct 15, 2007

The Trap™ Returns

Remember my rant about how dissatisfied I was with management at some company? I intentionally left out the details. Didn't want to talk about a particular person/company. Really. Just an innocent expression of my anger and wish for more people who have fundamental knowledge of what their employees do.
And guess what? One person I used to work with recently found that post and got very angry over it. Yeah, I know it wasn't nice, but it wasn't personal either. You really should take some things with a grain of salt, otherwise you can turn meaningless trifles into terrible nightmares and benevolent allies into worst enemies.
Besides that, YOU have ranted about me and my useless "technical correctness" a lot and very directly. And I don't go crazy about it. I work with different people now, and guess what? Just like me, they wouldn't agree with you that "it's practically impossible to have development and production version of software synchronized". These are you own words. And those... how did you call it? "Purely academic deliberations" that was. Do you still think that SVN, design patterns and unit tests have no use in real life applications?
I just hope that your employees will appreciate that I've introduced things like version control and some automated processes to your company. I guess you don't and probably think it was just a pointless waste of time. If that's the case... well, I'm sorry. I should have left you with the just-WinSCP-the-whole-thing-and-hotfix-live-on-the-server solution.
Anyways, I've gotta go finish my (pretty neat by the way) deskbar plugin for my next post. Wish you all the best (yes, I really do).

Oct 14, 2007

Ubuntu 7.10, rails, gedit and gtksourceview 2.0

In about 4 days a long awaited version of Ubuntu will be released. I'm not one of those who can just sit and wait for the final release, thus I've been already using Gutsy for a few weeks now.
The most visible changes include compiz turned on by default on capable hardware (that means intel-based cards and some of the ATI cards) and can be easily turned on on hardware that needs proprietary drivers (ie. AMD/NVidia and most ATI cards). Spotlight fans will be pleased to see tracker installed by default and deskbar on their top panels. Network manager got some love too, and now should work for many more users and be able to talk to a wider range of hardware.
The bad news is that deskbar has undergone a total GUI redesign, which turned out to be a big mistake - most people just hated it. Fortunately the maintainer of the app reacted quickly enough to get lots of bug fixes to Ubuntu's repos on time, so that deskbar is usable again (but it's still far from what it used to be). Another slight disappointment is the kernel version - Ubuntu got stuck with 2.6.22 (which is known to cause many problems) as 2.6.23 didn't make it before kernel freeze.
As a big rails fan I'm very excited about new gtksourceview, which supports context-aware syntax highlighting. That means we'll finally get properly colored Ruby syntax within erb blocks in gedit/scribes! But.. it's too good to work out of box, so you'll need some tweaking. I know there are some HowTos out there, but none of them "just worked" for me, so ... here's what I did.

Associate files with gedit

First of all check if you have a file called Override.xml in your ~/.local/share/mime/packages directory. If you do see if it has definition for x-extension-rhtml file inside - if you don't know how to speak XML just see if the "x-extension-rhtml" phrase exists somewhere in the file. If it does, delete the section containing the definition or, if you don't know how to properly edit XML file, just delete the whole Override.xml file. This is what took me about an hour to figure out as it overrides system-wide .rhtml definition and caused my system not to recognize rhtml files properly.

Now we need to teach gnome to recognize .rhtml files and give them their own mime-type. First, download the file with mime-type definitions for rails files. and copy it to /usr/share/mime/packages directory.

Then, as root, you'll need to update mime database. To do so, just use this command:

$ sudo update-mime-database /usr/share/mime

Now your Gnome should be able to recognize .rhtml files as text/rhtml mime-type. Now just right click on an .rhtml file, choose "Open with..." and use gedit/scribes to open the file. Nautilus should remember you want your favorite editor to open these files so from now on you can just double-click on a file to open it.

Context-aware syntax highlighting

Gtksourceview doesn't include definitions for rhtml files by default, so I've had to write them by hand. Here's the lang definition for RHTML files. Just download it and copy to /usr/share/gtksourceview-2.0/language-specs/ directory and restart gedit/scribes. And enjoy.

Code snippets


Everyone just loves code snippets, and now you can define a set of snippets specifically for RHTML files as it has it's own mime-type now! For some of you who are as lazy as I am, I've posted my code snippets for rhtml files. They aren't perfect, but I haven't had much time to work on them. Anyways I hope you'll find it useful. If you'd like to share your own snippets with others email me at robert_at_aenima_dot_pl and I'll post them here.

Other useful plugins

There are some plugins for gedit that can make your life easier. One of them is SnapOpen - it lets you quickly find a file in application's directory tree. Another plugin I use is Rails Hotkeys, which you can get from SVN by typing:

svn co http://svn.simplesideias.com.br/general/gedit/plugins/rails_hotkeys/

in the command line. Some people may find Class Browser plugin useful. It's pretty neat, but still very buggy. And of course I recommend to use the terminal plugin bundled with gedit.

Other resources (added 2008-09-29)

LT has created a nice cheat sheet for snippets for gedit available at http://www.scribd.com/doc/6299312/Gedit-Cheat-Sheet-for-Rails-Development (post in Spanish: http://lt1982.blogspot.com/2008/09/gedit-cheat-sheet-para-ruby-on-rails.html). Thanks!