5 ms·
Ruby Garbage Collection Deep Dive: GC::INTERNAL_CONSTANTS
- j4yav 6y agoAs someone learning Ruby and Rails at the moment, and who likes to learn things from the fundamentals, is there a good book or blog series that takes you through it? Because I’m helping on a Rails app I’m learning a lot of magic, which is awesome for productivity, but I feel like I’m missing some important concepts that tie things together.
- darkandbrooding 6y agohttps://github.com/The-Complete-Guide-to-Rails-Performance https://github.com/The-Complete-Guide-to-Rails-Performance I learned quite a bit about ruby memory mgmt from the above. Free text, pay for video tutorials IIRC. The course was authored by Nate Berkopec. https://www.youtube.com/user/nateberkopec https://www.youtube.com/user/nateberkopec I also found "the well grounded rubyist" to be very helpful. https://www.manning.com/books/the-well-grounded-rubyist-third-edition https://www.manning.com/books/the-well-grounded-rubyist-thir...
- rkowalick 6y agoThe Well-Grounded Rubyist is my favorite Ruby book because it really drives home just how internally consistent the Ruby object model is. It gave me a deep appreciation for the aesthetics of Ruby.
- burlesona 6y agoThis. Ruby’s syntax sugar makes it easy for newcomers to miss the elegance of what’s actually happening with everything being an object and every expression reducing to passing messages between objects. When you dig in and really understand what’s going on, the lightbulb moment is very neat.
- Toutouxc 6y agoI enjoyed 'Eloquent Ruby' by Russ Olsen. It feels nice and friendly, and it gives you a solid understanding of Ruby, the object model, how inheritance works, how and why to use metaprogramming and more.
- randmeerkat 6y agohttps://www.learnenough.com/ruby-on-rails-6th-edition https://www.learnenough.com/ruby-on-rails-6th-edition
- pkd 6y agoIf you want to get into the internals of Ruby then I'll recommend Ruby Under a Microscope.
- matheusmoreira 6y agoThe magic of garbage collection revealed: http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ http://journal.stuffwithstuff.com/2013/12/08/babys-first-gar...
- didymospl 6y agoThis might be only slightly related to this post but I started wondering: how often do you have to tweak GC in your job? Do you ask/are you asked questions about GC on interviews? I've just realized that I was asked about this stuff in almost every Java interview I had, sometimes the questions were very detailed (and I was nowhere near HFT or any other real-time systems, GC pauses were minor concerns) but for jobs focused on other languages this topic is almost completely skipped.
- ajakate 6y agoMaybe only a little related, but in the five-ish years of ruby dev I've done, there was only one time I can remember interacting with the GC directly in production code. It was in the context of a sidekiq job that was importing customer data via csv file. We would read in the csv, and for each row a lot of complicated logic was being performed that would translate the data from customer format into our format, and decide how to update different tables in db. These files were sometimes 10k lines or longer (all handled by a single sidekiq job), and would balloon up in memory so much that sidekiq would crash and would keep trying to restart the job. For each row we were instantiating an ActiveModel object that had a lot of attributes/functions. I think the right solution would have probably been to do a (fairly heavy) refactor of that area in the code, and spin up a separate job for each row, but we found that by running a GC.start every few rows we were able to cleanup some of the old AM objects and keep the memory usage low for the time being...
- sethhochberg 6y agoMirrors my experience as well. Nearly a decade of working on large Ruby/Rails apps, some with very complex reporting / data processing flows (talking like billions of db rows processed in streaming queries, media encoding, etc) and a particular CSV processing situation like yours was the only time I needed to manually trigger GC... and even that was just triggering it, not even tweaking it. The defaults seem very good, even at scale.
- winrid 6y ago
- dang 6y agoRecent and related: Ruby Garbage Collection Deep Dive: Tri-Color Mark and Sweep - https://news.ycombinator.com/item?id=26182796 https://news.ycombinator.com/item?id=26182796 - Feb 2021 (15 comments)
- deleted 6y ago[deleted]