4 ms·
This article enrages me. I totally agree with codinghorror that a blog without comments in not a blog, this is a prime example. No way to respond to the author
by sams99 13y ago
This article enrages me.
I totally agree with codinghorror that a blog without comments in not a blog, this is a prime example. No way to respond to the author without jumping through crazy hoops.
As to the issue.
1. NEVER use unicorn oobgc that ships with unicorn or the old one that ships with passenger. Use gctools on 2.1.1 https://github.com/tmm1/gctools https://github.com/tmm1/gctools or this on 2.0 http://samsaffron.com/archive/2013/11/22/demystifying-the-ruby-gc http://samsaffron.com/archive/2013/11/22/demystifying-the-ru.... If you are disabling GC you are doing it wrong and creating rogue processes.
2. Expect memory doubling with Ruby 2.1.1. Not happy with that? You have 2 options. Tune it down by reducing RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR. At 1 your memory consumption will be on par with 2.0. It ships with the 2 default. Option 2, wait for a future release of Ruby, this will be fixed in 2.2 maybe even patched a bit more in 2.1.2 . See: https://bugs.ruby-lang.org/issues/9607 https://bugs.ruby-lang.org/issues/9607 and http://vimeo.com/89491942 http://vimeo.com/89491942 and https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-...
As for the, full-of-bait, title. Ruby's GC is ready for production and being used in production in plenty of places. Just don't go expecting rainbows if you disable it. And expect memory doubling with 2.1.1 if left untuned. You can choose how much you want the memory to increase from 2.0
- timr 13y agoOK, I'll bite. First, sorry we don't have comments yet. I'm the author, so you no longer have to be enraged. Perhaps just annoyed. Second, with Ruby 2.1, out of the box, this code: while true do "a" * (1024 ** 2) end leads to infinite process growth. There should be no need for "memory doubling" to run this code -- you're generating throwaway strings of identical size. Similar code, in other languages, does not lead to out of control memory consumption. Also, the problem isn't caused by disabling the GC. This happens in stock Ruby 2.1. Disabling the GC (and running it once per request) is the fix for the problem.
- vidarh 13y ago> There should be no need for "memory doubling" to run this code -- you're generating throwaway strings of identical size. How do you know they are throwaway? Your code involves two method calls. While it would be unlikely that someone has overridden them given that they are core String and Fixnum methods, it is perfectly possible. E.g: class String; alias :old :* def * right $store ||= [] $store << self old(right) end end "foo" * 5 "bar" * 3 p $store In other words, even with seemingly innocent calls like that, it takes extra work to be able to reuse that memory without a full GC pass. It's certainly not impossible, but it's not there yet. So I agree with you in principle, but this is one of those areas where the malleability of Ruby objects makes it tricky to optimize. (one possible example approach is to set aside a bit to indicate "has at least once been stored somewhere where it can escape" as "poor mans escape analysis" - if your object is only ever stored in local variables that have no been captured by a lambda, or passed as arguments, then it can't escape higher than where it was created, and so you can take shortcuts, otherwise you'd still need a full gc pass)
- sams99 13y agoThat sir, is a bug that should be reported on bugs.ruby-lang while true do "a" * (1024 ** 2) end it is to do with the dynamic malloc limit growing too much, should be fairly trivial to patch in the next 2.1 release
- bqe 13y agoOkay, about blogs without comments: My blog doesn't have a comment section. It's because I sometimes post controversial opinions and I don't want the garbage that often pollutes comment sections ending up permanently attached to my writing. You can't delete overly negative comments without seeming like a fascist, so what do you do? I prefer to submit my posts to HN or other sites where people can comment and not have their comments permanently attached. As for Jeff Atwood's comparison of a blog without comments to a pulpit, that's ridiculous. Does he also hate books and essays? My blog is simply a collection of essays.