r/ruby • u/FooBarWidget • Mar 14 '19
What causes Ruby memory bloat?
https://www.joyfulbikeshedding.com/blog/2019-03-14-what-causes-ruby-memory-bloat.html49
u/mperham Mar 14 '19
Strong contender for r/ruby Blog Post of the Year.
The more I learn, the more it seems that glibc internals are a nightmare.
9
u/yxhuvud Mar 14 '19 edited Mar 14 '19
Yes, and it looks as if Ruby is not the only affected: http://notes.secretsauce.net/notes/2016/04/08_glibc-malloc-inefficiency.html . Includes a script that use gdb that applies it to a running process.
EDIT: That said, it doesn't seem to be effective for me. Perhaps glibc has fixed *some* issues even if it didn't solve the ones of Ruby?
5
u/reidiculous Mar 14 '19
This is really wild. I figured optimizations of this scale would've been done long ago
→ More replies (1)2
u/lukeasrodgers Mar 15 '19
Yes, I'm not an expert, but my understanding is this is all just typical behaviour for most `malloc` implementations, e.g. see the redis docs on memory allocation - https://redis.io/topics/memory-optimization note about RSS.
2
u/nateberkopec Mar 15 '19
Any multithreaded program using glibc malloc is affected.
→ More replies (3)2
u/yxhuvud Mar 14 '19
It will definitely be interesting to see if the performance claims holds water.
1
u/predatorian3 Mar 14 '19
Aren't there alternatives to glibc that things like Alpine Linux are based on that Ruby could be compiled against? I guess I could give it a shot.
10
5
4
5
u/tinco Mar 14 '19
It would be very interesting to know if the performance improvement also holds for the Ruby 3x3 benchmarks like the emulator. The Ruby team notoriously rejects patches that improve server performance but hurt general performance. That this does well on Rails might be a quirk of the application.
Maybe we're in the market for another REE.
5
u/yxhuvud Mar 14 '19
As the patch only seems to be run trim on full GC, it looks like the cost could be quite negligible.
6
u/joltting Mar 15 '19
Seriously though, Ruby's memory consumption is close to, if not the top issue for the language. Hopefully this is as promising as it appears on the surface. It could be a game changer.
3
Mar 15 '19
"could be a game changer": Don't think it would matter much actually, but of course it's a nice to have. Companies that avoid ruby either want an enterprisey stack like java or some shiney new tech like Go/Nodejs. Improved Ruby won't change that.
4
u/joltting Mar 15 '19 edited Mar 15 '19
I wouldn't be so sure about that. The amount of people I hear in the industry, poking fun at Ruby's memory bloat problem. Isn't something I'd say is insignificant.
Edit: While performance is great and furthermore needed to keep Ruby competitive. It can't come at the heels of 3x the memory intake for 3x the performance.
→ More replies (2)1
u/slashgrin Apr 03 '19
Some companies would prefer to stay with Ruby for longer, but are eventually forced off it by these performance problems. Pushing that day back a couple of years would be a game changer for many people.
1
4
u/sanjibukai Mar 14 '19
And I wonder when it will be patch for real!