4

When upgrading from Ruby 1.8.6 to Ruby Enterprise 1.8.7 p334, the memory size has nearly doubled. This has occurred in every one of the five Fedora 8 servers we upgraded. We run Rails 1.2.6 with Passenger 3.0.4.

Munin gets the memory size for every process by summing the vsz and rsz columns from $ ps axo pid,comm,pmem,vsz,rsz. (The virtual memory size and resident memory size both increase the same amount)

I realize that these columns generally overstate the amount of memory actually used by the processes, but if this was used to measure 1.8.6 and then 1.8.7 REE, they should be equally bloated, and therefore still comparable.

In addition, the committed memory for the machine (as listed in /proc/memstat) is now regularly overcommitting, which is new. The amount committed memory has increased significantly, and it looks like we're now into swap space.

We have not yet tuned the garbage collection, but I can't see how that would affect the overall memory footprint.

I have turned on the GC.copy_on_write_friendly variable as recommended by the Phusion FAQ.

What is the explanation for this 100% increase in memory usage and how can I fix it? Any ideas on how to fix, or even better monitor/debug, are appreciated.

Thanks.

---UPDATE

In order to check performance, I have decreased the number of running instances (PassengerMaxPoolSize) from 12 to 10 on one server. On another, I have raised the PassengerPoolIdleTime to 15 minutes. I have a third that is being used as a control.

I'm considering putting a non-enterprise version 1.8.7p334 on a server to see if it's 1.8.7 or the Enterprise Edition.

Anyone else have any experience with this type of issue?

Looking at the individual Rails processes, they are about 120MB per process in 1.8.6, and 175MB/process in REE 1.8.7, as stated by passenger-memory-stats.

---UPDATE 2

I put MRI 1.8.7 on a server for comparison to REE 1.8.7. The results were worse, including higher memory resident size number and passenger-memory-stats. Of course, swapping started.

This is leading me to believe that 1.8.7 simply has a larger footprint than 1.8.6.

---UPDATE 3

I put MRI 1.8.7 on a server, it was much worse that MRI 1.8.6 in terms of memory usage, so I immediately went back to MRI 1.86.

I've run an average of Rails process size, as listed by passenger-memory-stats. The REE 1.8.7 processes were 73 MB larger, which seems rather large.

This means that I need to have significantly less processes running to fit in the same memory footprint.

Will see how they perform with fewer processes. I'm also starting the GC tuning.

---UPDATE 4

Seems Ruby 1.8.7 does not support Rails 1.2.6. The first officially supported version of 1.8.7 is Rails 2.1. We'll know after the upgrade if that's the root of the problem.

trimbletodd
  • 317
  • 1
  • 10
  • Are you also looking at the output of [passenger-memory-stats](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_inspecting_memory_usage)? – nickgrim Mar 09 '11 at 21:36
  • Yes. passenger-memory-stats has increased as well, although less significantly. Reducing the PassengerMaxPoolSize and PassengerPoolIdleTime both helped to reduce the memory from passenger-memory-stats. The resident memory decreased slight as well, but no significantly enough. – trimbletodd Mar 10 '11 at 14:00
  • Have you checked to make sure you aren't running a 64-bit version of Ruby now? – Doug Barth Mar 21 '11 at 21:42
  • It makes more sense to ask such a question on the Passenger discussion group ( http://groups.google.com/group/phusion-passenger/topics ). Hongli Lai, and the other guys from Phusion are very active on it. – Ronen Botzer Mar 23 '11 at 02:24
  • Sorry for the delay. Yes, we are running 64bit ruby. And yes, I did start a [thread](https://groups.google.com/forum/#!topic/emm-ruby/4ZpKMdWsbek) on the googlegroups phusion-passenger topics, where I received some good response. No silver bullet, however. – trimbletodd Apr 04 '11 at 21:30
  • 1
    Wait, so you switched from 32bit to 64bit and are wondering why your memory usage increased? – Rein Henrichs Apr 11 '11 at 19:05
  • Honestly, I hadn't considered the increased memory usage of switching to a 64-bit ruby. As I think about it, that would have significant impact on the memory footprint. It's tough to see it increasing so significantly, but in combination with the increased memory size of 1.8.7 compared to 1.8.6, I might buy it. – trimbletodd Apr 14 '11 at 18:40
  • Pointers in 64-bit apps are automatically double the size, and in a language that uses a lot of pointers, like Ruby, you can end up paying a huge price. – tadman May 10 '11 at 00:54

1 Answers1

3

You went from a 32-bit version of Ruby to a 64-bit version of Ruby. This doubles the size of pointers, of which there are many in the runtime.

Phrogz
  • 296,393
  • 112
  • 651
  • 745