Month: August 2009

Dívidas e nova seção

Posted by – 31/08/2009

Eu sei, eu sei. Há muito que estou devendo uns posts aqui, principalmente de uma série que deixei inacabada, mas sabem como é… voltei de férias mas todo o resto continuou andando… Recém consegui colocar as coisas em dia e, para piorar, descobri problemas em alguns dos meus códigos que necessitaram atenção imediata (sobre isso farei um post em breve)…

Então esse post é para dizer que reconheço essas dívidas, e que estarei saldando elas em breve. Mas também, com esse post, inauguro uma nova seção nesse blog: a seção Propus. Os posts dessa seção serão agregados no blog da Propus, junto com as postagens dos outros diretores e dos funcionários da Propus.

Happy hacking / blogging.

Fighting Memory Leaks

Posted by – 17/08/2009

I love to code in Ruby… I’ve stated that many times. It’s a simple, intuitive, unobstrutive language good for quick prototyping and has a lot of good libraries around. There’s one annoiance, though, that every now and then pops up and makes my life miserable. For the last 10 days I’ve been fighting (and loosing) a battle against a memory leak… And this is its story:

I’ve told you that my company has some internal projects using XMPP. I’ve even published a fork of XMPP4R-Simple and presented it in FISL10. XMPP4R, which is the library underneath it, has causing me problems (at least I think it is guilty). This project has a lot of parsing and message/events exchange between XMPP agents. Everything is fine with the test suite and development tests went ok… but when I got it into production, it lasted a day before even the most simple test end up eating all the memory in the server.

Of course… my first thought was that our parser was the guilty one. It’s common knowledge that implementing parsers is not so intuitive in Ruby and one has to pay attention to some glitches not to end up in a memory leak (Why has commented about it before). I’ve rewrote the entire parser and the same behaviour emerged… I’ve even began considering using Treetop and stop worrying about parse construction (I hope treetop would do it The Right Way(tm)), but then I decided it’s worth a little research on the issue.

First, I tried to recompile Ruby 1.8.7 (I was using the one packaged for Debian). Same behaviour. Then I’ve tried Ruby 1.9.1 (I already had it compiled, but I recompiled it anyway 😉 ). Same behaviour. I would not like to try JRuby: even if it fixes the memory leak, it will not be available in all production environments we expect…

This brought me to the important conclusion that there’s no really good tools for memory profiling Ruby programs. There’s a lot of attempts and some even get you an idea of what’s going on, but nothing that points to the really obvious “perpretator” of a memory leak… Also, many people have dealt with this before and it seems to be a pain for everyone.The problem just grows with the complexity of your program and the number of dependencies. To break it up for my case, I designed a Test Case that would require only basic stuff and do the minimal thing (it’s really nothing big and a bit hackish, but it spits a lot of info on what is going on)…

I ended up convinced that either XMPP4R or REXML (which comes with Ruby) are leaking memory (maybe both). Even if it is REXML the faulty library, I suspect XMPP4R guys would like to know about it and would help me to narrow it down. At their home page they even list some desired information on bug reports:

  • Contact information
  • XMPP4R version or Git SHA1 commit
  • Use Jabber::debug = true but remove any sensitive information
  • Describe your environment (Ruby version, OS, server software)
  • Cool hackers send test cases

All obvious stuff, and since I’ve already built a test case

Colonia Del Sacramento

Posted by – 06/08/2009

After the most pleasant time in Montevideo, we went to the city of Colonia. This is a historical town disputed by Portugal and Spain during the early days of South American continent. The historical part of the town is called Colonia del Sacramento, which is the original name of the town.

Colonia is a calm and beautiful town. Surely a place to rest while contemplating the awesome view, spending time in the historical sites and walking by Rio da Prata (Silver River) shore:

Since it was disputed during a long time, the old town is a fortified one. Remainings of the fortification can be seem everywhere. In this picture one can see Brenda holding the chains of the Main Gate>

It’s safe to walk the old town even after sunset and there are some pubs that are open until late surrounding the Plaza Major (Large Square) where one can spend a pleasant time, even if it’s cold -such as during the time we’re there. The sunset, itself, happens over the river… a gift of its own:

Brenda and I had a wonderful time in Colonia. We hope to go back there sometime.

Montevideo, finally

Posted by – 01/08/2009

After our almost landing in Montevideo, we finally managed to land there the day after, but not without emotion: the plane had to go up one more time before finally landing at MVD. Again they told us the winds were too strong, but at least they haven’t brought us back to Porto Alegre this time.

We spent 4 days in Montevideo (would be 5, but we lost one due to those winds) and 3 days in Colonia. Montevideo is really beautiful. I was told by many people that had gone there before, that I would like it, and I was not disappointed at all. There was almost no traffic, taxis were really cheap (so that I gave up renting a car – going by bus was a good option, but with such cheap taxis we just decided against waiting in the cold for the bus), people are kind, food is really good and there’s enough history to keep Brenda and I happy.

Of course I took some pictures:

Above I am standing in front of the Palacio Legislativo) (where people representatives make the country law).

Nearby our hotel we walked in front of Parva Domus Magna Quies, which is a kind of relaxation and contemplation brotherhood that began with a fisherman society in 1878. Amazingly Google knows so little about it (this was the best I could find) and I found nobody that could add to it. Nevertheless I took a picture of the inscription:

Another place I really wanted to visit was Estadio Centenario, and although it was closed I managed to convince the gatekeeper to allow me to take some pictures. Here is one:

At night, Montevideo offers a lot of options and, of course, we went to a lot of Parilladas and visited some “must-go” places (such as the Bar Fun Fun). All in all, a good place to visit, even if you just have a couple of days.