Memory Usage Doubled by moving from 32-bit to 64-bit

631 views
Skip to first unread message

Vince

unread,
Mar 25, 2011, 3:02:21 PM3/25/11
to Phusion Passenger Discussions
Hi,

We switched to 64-bit system (linux + REE + passenger 3.0.0) and we have noticed that memory used by passenger processes more than doubled. The is no change to our application or traffic pattern or gems used so we are not sure what's going on.

Can somebody recommend a good way or a good tool to debug this issue?

Thanks,

Vince

Hongli Lai

unread,
Mar 25, 2011, 3:11:27 PM3/25/11
to phusion-...@googlegroups.com

This is normal. On 64 bit all pointers are double the size. MRI is implemented with a lot of pointers so all Ruby apps use almost twice the memory. Go back to 32 bit if you don't like this.

Sent from my Android phone.
Op 25 mrt. 2011 20:07 schreef "Vince" <coolte...@gmail.com> het volgende:

> --
> You received this message because you are subscribed to the Google Groups "Phusion Passenger Discussions" group.
> To post to this group, send email to phusion-...@googlegroups.com.
> To unsubscribe from this group, send email to phusion-passen...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/phusion-passenger?hl=en.

seth

unread,
Mar 30, 2011, 2:08:57 PM3/30/11
to Phusion Passenger Discussions
Wow! This is surprising to me. I expected the ratio of pointers to
data to be fairly low (25%, not 100%). Of course I haven't spent a
lot of time in the ruby source...

Does anyone have any experimental data to back this up?

It would be interesting to see a memory comparison of a rails project
running the following combinations (latest version of ruby
enterprise):

1. 32-bit OS with 32-bit interpreter
2. 64-bit OS with 32-bit interpreter
3. 64-bit OS with 64-bit interpreter

I bounced out to the ruby enterprise website and only found the base
32-bit memory comparison on using the 1.8.6 version of ruby on a
fairly old ubuntu (2007). http://www.rubyenterpriseedition.com/comparisons.html
Is there an updated version someplace else?

We were also surprised by the massive jump in memory usage as well
when we migrated to 64-bit. Our processes jumped from ~100MB ->
~210MB. I'll update the thread if it turns out the 32-bit interpreter
running on the 64-bit OS solves the problem. None of our processes
need to access close to 4G so this might be an option for us.

Kind of a sharp reply for an honest question...

Seth

On Mar 25, 2:11 pm, Hongli Lai <hongli...@gmail.com> wrote:
> This is normal. On 64 bit all pointers are double the size. MRI is
> implemented with a lot of pointers so all Ruby apps use almost twice the
> memory. Go back to 32 bit if you don't like this.
>
> Sent from my Android phone.
> Op 25 mrt. 2011 20:07 schreef "Vince" <cooltechem...@gmail.com> het

Hongli Lai

unread,
Mar 30, 2011, 2:54:02 PM3/30/11
to phusion-...@googlegroups.com, seth
On Wed, Mar 30, 2011 at 8:08 PM, seth <seth...@gmail.com> wrote:
> Wow!  This is surprising to me.  I expected the ratio of pointers to
> data to be fairly low (25%, not 100%).  Of course I haven't spent a
> lot of time in the ruby source...
>
> Does anyone have any experimental data to back this up?

On pretty much all our production servers, Ruby on 64-bit systems uses
about twice the memory. I've yet to see one scenario where this is not
the case.

--
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Isaac

unread,
Mar 30, 2011, 3:18:20 PM3/30/11
to Phusion Passenger Discussions
Are there any known downsides to running a 32-bit interpreter on a 64-
bit OS? (Or to running a 32-bit interpreter in general?) Just
wondering if 64-bit ruby gets us anything useful, considering it costs
twice as much memory.

Hongli Lai

unread,
Mar 30, 2011, 4:04:45 PM3/30/11
to phusion-...@googlegroups.com, Isaac

You can map twice as much memory in the virtual address space. Nobody
likes to writes Ruby apps that consume more than 2 GB of memory, but
this fact does mean that you can for example mmap() a 64 GB file and
use it. Other than that, I don't think there's any advantage in
running Ruby on 64-bit systems. I recommend running it on 32-bit if
memory is a big issue for you.

Vince

unread,
Apr 2, 2011, 6:24:43 PM4/2/11
to phusion-...@googlegroups.com, Hongli Lai, Isaac, seth...@gmail.com
is there anyway to use 32-bit rails/passenger on 64-bit system?

Like Seth, our memory usage jumped from 100MB/32-bit to 200-250MB/64-bit. 


--

Curtis j Schofield

unread,
Apr 2, 2011, 7:26:58 PM4/2/11
to phusion-...@googlegroups.com, Vince, Hongli Lai, Isaac, seth...@gmail.com
you could try building the binaries for 32 bit

export ARCH="x86"

may work for ruby / apache / passenger-apache

--
make haste slowly \
festina lente  \
-
mobile  +1_415_632_6001
curtis.s...@gmail.com
http://robotarmyma.de

Hongli Lai

unread,
Apr 3, 2011, 3:46:59 AM4/3/11
to Vince, phusion-...@googlegroups.com, Isaac, seth...@gmail.com
On Sun, Apr 3, 2011 at 12:24 AM, Vince <coolte...@gmail.com> wrote:
> is there anyway to use 32-bit rails/passenger on 64-bit system?
> Like Seth, our memory usage jumped from 100MB/32-bit to 200-250MB/64-bit.

Yes, install a 32-bit Ruby, 32-bit web server and a 32-bit Phusion
Passenger on the system. Compilation method depends on the OS. Or you
can build on a 32-bit system and copy the binaries over.

Isaac

unread,
Apr 2, 2011, 6:58:38 PM4/2/11
to Phusion Passenger Discussions
I've tried compiling ruby for 32bit on a 64bit os, and it basically
works (and uses much less memory!) but gets complicated as you start
to compile gems later and need to be careful about setting compiler
options correctly, and apache may also need to be 32bit if ruby is.

This is the command I was using to get ruby compiled as 32 bit (and
installed in /opt/ruby-1.8.6-p287_i386 so I could test it separately
from other ruby versions):

wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p287.tar.gz
tar xzf ruby-1.8.6-p287.tar.gz
cd ruby-1.8.6-p287
export CFLAGS=-m32
export LDFLAGS=-m32
setarch i386 ./configure --prefix=/opt/ruby-1.8.6-p287_i386 --disable-
pthread
make
make install

The passenger gem did install fine on top of that, but then passenger-
install-apache2-module kept complaining that I needed to install curl-
devel (even though I had both the 32 and 64 bit versions installed).
This was on CentOS 5.5 x64. I also ran into issues compiling a few
gems required for my app, so I gave up, for now.

This might be better for the REE mailing list, but it would be awesome
if REE worked well for compiling in 32 mode on a 64 bit OS.

My preference would be for the OS to be 64bit, as I generally run the
db on the same box, and it can really take advantage of being able to
allocate larger amounts of memory. Otherwise I would just use a 32bit
OS.

- Isaac

On Apr 2, 3:24 pm, Vince <cooltechem...@gmail.com> wrote:
> is there anyway to use 32-bit rails/passenger on 64-bit system?
>
> Like Seth, our memory usage jumped from 100MB/32-bit to 200-250MB/64-bit.
>
>
>
>
>
>
>
> On Wed, Mar 30, 2011 at 1:04 PM, Hongli Lai <hon...@phusion.nl> wrote:
> > On Wed, Mar 30, 2011 at 9:18 PM, Isaac <is...@reuben.com> wrote:
> > > Are there any known downsides to running a 32-bit interpreter on a 64-
> > > bit OS?  (Or to running a 32-bit interpreter in general?)  Just
> > > wondering if 64-bit ruby gets us anything useful, considering it costs
> > > twice as much memory.
>
> > You can map twice as much memory in the virtual address space. Nobody
> > likes to writes Ruby apps that consume more than 2 GB of memory, but
> > this fact does mean that you can for example mmap() a 64 GB file and
> > use it. Other than that, I don't think there's any advantage in
> > running Ruby on 64-bit systems. I recommend running it on 32-bit if
> > memory is a big issue for you.
>
> > --
> > Phusion | Ruby & Rails deployment, scaling and tuning solutions
>
> > Web:http://www.phusion.nl/
> > E-mail: i...@phusion.nl

Hongli Lai

unread,
Apr 4, 2011, 11:36:09 AM4/4/11
to phusion-...@googlegroups.com, Isaac
On Sun, Apr 3, 2011 at 12:58 AM, Isaac <is...@reuben.com> wrote:
> I've tried compiling ruby for 32bit on a 64bit os, and it basically
> works (and uses much less memory!) but gets complicated as you start
> to compile gems later and need to be careful about setting compiler
> options correctly, and apache may also need to be 32bit if ruby is.

Apache doesn't need to be 32-bit. Phusion Passenger uses a
split-process model whereby processes communicate with each other
through IPC and don't care what architecture each other is compiled
for.

> The passenger gem did install fine on top of that, but then passenger-
> install-apache2-module kept complaining that I needed to install curl-
> devel (even though I had both the 32 and 64 bit versions installed).

Yeah though that's a problem in our build system. Our build system
currently assumes that there is only 1 architecture on the system. You
could work around this by compiling Phusion Passenger on both 32-bit
and 64-bit systems and merging the results. You need to take
mod_passenger.so from the 64-bit system and
passenger_native_support.so from the 32-bit system. The binaries in
agents/ can be of any architecture.

--
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

AliQuli

unread,
Apr 5, 2011, 10:58:18 AM4/5/11
to Phusion Passenger Discussions
While memory consumption is reduced with 32-bit apps, there is a
possible performance tradeoff since most server processors have
dedicated 64-bit registers that cannot be used by a 32-bit app. Do
ensure you've evaluated all the tradeoff's before pushing this to
production.
regards
Ali

http://www.7vals.com
> E-mail: i...@phusion.nl

Hongli Lai

unread,
Apr 5, 2011, 1:28:46 PM4/5/11
to phusion-...@googlegroups.com, AliQuli
On Tue, Apr 5, 2011 at 4:58 PM, AliQuli <ali...@gmail.com> wrote:
> While memory consumption is reduced with 32-bit apps, there is a
> possible performance tradeoff since most server processors have
> dedicated 64-bit registers that cannot be used by a 32-bit app. Do
> ensure you've evaluated all the tradeoff's before pushing this to
> production.

A valid point, though I dare to argue that nobody uses Ruby for
computationally-expensive operations anyway. Ruby web apps are usually
heavy on I/O and memory operations and my experience is that the
64-bit registers don't help Ruby performance that much anyway.

--
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

seth

unread,
May 20, 2011, 9:21:49 AM5/20/11
to Phusion Passenger Discussions
I just wanted to report that we have run using 32-bit binaries on 64-
bit debian. Memory usage is restored to pre-64-bit levels.

It's a bit of a pain to get working, but we think it was worth it (ldd
is your friend :)).

Seth
Reply all
Reply to author
Forward
0 new messages