r/programming • • Feb 24 '13

Ruby 2.0.0

http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/
600 Upvotes

193 comments sorted by

View all comments

7

u/postmodern Feb 24 '13 edited Feb 24 '13

They also replaced mark/sweep with optimized GC using bitmap marking to make it copy-on-write friendly!

12

u/drbrain Feb 24 '13

The GC is still mark/sweep, it now uses a bitmap to store the marks instead of flags on the object.

6

u/pnwf Feb 24 '13

This is huge. For so long doing anything that requires concurrency in Ruby was a tradeoff between using threads and suffering through weird hard-to-reproduce threading bugs and taking the performance hit of the GIL/GVL, or fork()ing and taking the memory hit when all your child processes' GCs force them to each have their own copy of memory that should be shared since it is never modified.

3

u/tuna_safe_dolphin Feb 24 '13

Wait, so does this mean Ruby no longer has a GIL? I'm mostly a Python programmer - I'd love if the GIL went away in Python.

5

u/nirvdrum Feb 24 '13

It still has a GIL/GVL, but all those forking app servers will save a ton of RAM. I'd read suggest reading the articles from the Passenger guys on REE and Passenger for a thorough treatment on the GC benefits.

1

u/Amadan Feb 24 '13

I'm not very good at low-level, so... Does this mean GIL is gone? Or at least soon-to-be-gone?

6

u/cartola Feb 24 '13

The GIL isn't gone and there isn't an end in sight. It has been "renamed" to GVL (Global VM Lock), but as Aaron Patterson said in one talk it's the same thing. VMs are hard and Matz prefers Ruby's VM to be simple and easy to understand to being extremely fast and optimized at the cost of maintenance.

Taking out a GIL isn't easy and the CPython guys apparently did it some ancient time ago and experienced performance degradation (or it wasn't as great as once thought). The best VM without one is the JVM, so JRuby is the best bet. It'll probably never leave MRI.

1

u/Amadan Feb 24 '13

Thanks!

1

u/drbrain Feb 25 '13

One of the improvements Nari wishes to make is to have the GC be GVL-free.

It's gradually being pushed out of CRuby, but it's not easy to do so and keep performance. I remember FreeBSD pushing it's global lock out of the kernel, it took quite a long time to do all the tuning to get their speed back.

That will leave the VM and C extensions under the GVL. For C extensions it's fairly easy to release the GVL when they are doing work.

PS: Ruby has never had anything called a "GIL". The lock was added around the same time the ruby switched to a VM, so it has always been a global VM lock.

-5

u/KagakuNinja Feb 25 '13

In other words, Matz would prefer that Ruby remain a toy language, because writing a VM is hard.

4

u/AngelLeliel Feb 25 '13

I dont think "toy language" is a good term to refer languages not put the performance as the first priority.

→ More replies (2)

1

u/mogrim Feb 25 '13

s/hard/expensive/g

0

u/galtthedestroyer Feb 24 '13

What's a gc?

16

u/[deleted] Feb 24 '13

Garbage collector. To ELI5 it goes and finds all of the memory you aren't using and releases it back to the operating system.

1

u/icewatersteam Feb 24 '13

I'm not a ruby expert but in this instance I think gc refers to garbage collector.

Garbage collectors are a part of the runtime that looks for memory used up by the program that is no longer used and then frees up that memory to be used by something else.

0

u/[deleted] Feb 24 '13

[deleted]

3

u/icewatersteam Feb 24 '13

I didn't think my comment implied that but you're correct. Garbage collectors are not a exclusive ruby feature. They are used in many different runtimes (CLR, JVM etc.)

3

u/philly_fan_in_chi Feb 24 '13

If you know what a GC is, it definitely did not imply it. But for someone who didn't, they could get confused. Just looking out for the lowest common denominator.

4

u/icewatersteam Feb 24 '13

True, it sometimes hard to get back back to that beginner mind when explains something. Thanks for pointing it out.

1

u/eek04 Feb 25 '13

If you want to edit your original comment, I think just replacing "the runtime" with "a language runtime" will make it impossible to understand as Ruby specific.

-1

u/OhPleaseDontBe Feb 24 '13

I don't understand why this gets downvoted.

6

u/sootzoo Feb 24 '13

i didn't downvote, but this is /r/programming and the OPs answer is a very trivial Google search away.

3

u/galtthedestroyer Feb 25 '13

At the time I figured a 2 letter acronym would be hard to search for. When I got the answers I had to laugh. No one where I'm from abbreviates garbage collector.

It was definitely a brain fart on my part. Still the people who gave super through answers are awesome.

2

u/x86_64Ubuntu Feb 25 '13

One of the reasons a trivial question shouldn't be downvoted is because it can enhance discussion about the subject at hand.