Incremental garbage collection is great for realtime-ish use cases like games and multimedia, too, because if you tune the collector right, you can ensure your GC never causes you to drop frames or fail to mix a sound buffer on time.
Need to hit vsync every 16ms? Just run a 1-3ms incremental GC every frame when you have time to spare, and as long as your game's theoretical performance is good enough, you won't ever hitch. This is one of Lua's advantages for game scripting because it's had a fairly solid incremental collector for a while, making it easy to give the GC a fixed chunk of time to operate in every frame so your game never pauses.
Scripting is a huge boon for people doing game development, game prototyping, and multimedia scripting (toolsets like Processing, for example), so having another scripting language to choose from for that is awesome.
Hence the "effectively" in the parent comment; Ruby's interpreter lock can be very problematic in threaded apps that use I/O functions from C-based gems that forget to release the lock.
I don't understand what this means... Can you explain?
Here's my basic understanding:
MRI is a single process, with multiple threads... They can't run in parallel because of the global interpreter lock (which is used because the code in MRI is not thread safe? Meaning each thread can touch the same memory and may leave it in a broken state for another thread, so we lock access to it first...).
So: there are multiple threads, I am guessing each with their own task (maybe one to run the code, one to do garbage collection, ... I have no idea), but because of the GIL they can't be parallelized. Still multi-threaded anyway.
You can create multiple OS-level threads in MRI using Thread.new. Those threads can run code at the same time, just not Ruby code. There is a function that C extensions are supposed to call while running I/O that can block, or while running CPU-intensive non-Ruby code, that releases the global lock.
This is a completely pointless semantic distinction that nobody cares about.
What makes threads interesting is parallelism; if the goal is merely cooperative or pre-emptive multitasking, where there's no concurrency, then you're "effectively" not multi-threaded as per any modern expectation.
If threads aren't interesting except for parallelism, what do you think people were using them for the multiple decades when the vast majority of people were running single-cored uniprocessor systems?
The answer is that it's often useful to manage multiple things at the same time, even if we can't or don't want to actually do them at the same time.
We may want to use blocking IO for the simplicity it gives us compared to asynchronous IO, but allow other parts of the system to continue to run during that blocking.
We may want to let threads and the kernel manage our context and context switches for us, instead of manually storing and restoring state, because it can be simpler that way.
> If threads aren't interesting except for parallelism, what do you think people were using them for the multiple decades when the vast majority of people were running single-cored uniprocessor systems?
They largely weren't. POSIX threads weren't standardized and widely adopted until the 90s, and it wasn't until multi-processor systems became more prevalent that threads saw wide adoption at all.
o thats nice, is there something like that for creating visuals for vj-ing through ruby code - or are there ways to integrate the ruby generated music with ruby generated visuals?
So the keyword argument speed-up is pretty insane, but how does it compare to normal positional arguments? Is there an advantage over them too? In the bigger picture, there's obviously arguments for and against keyword arguments (biggest one is increasing connascence).
Well, you're trading connascence of position for connascence of name, which in this case is much better because you are providing context for the argument data.
Ruby is a wonderful language. It would be great if there was some deep-pocketed multinational willing to fund its development in the same way as Facebook has done for PHP or Google has done for Python.
Heroku pays Ko1 and Matz [0], and Heroku is owned by Salesforce, which is a public company. Granted, Salesforce doesn't have Google or FB's war chest -- but it's not like Ruby isn't being supported by companies.
Apart from Koichi, there's one more person - Nobu - who is working on CRuby full-time. Nobu's the guy with most commits to CRuby. Matz now does not work on CRuby, only on MRuby and the language specification.
It's also worth noticing that another implementation, JRuby is supported by Redhat. IIRC 2 people work on it full-time: Charles Nutter (Headius) and Thomas Enebo
There's a few of us at Oracle working on an alternative backend via JRuby, as well. Chris Seaton gave a talk on it at RubyConf last week. He has a series of posts about it that are pretty good:
Obviously, this isn't people being directly paid to work on MRI, but there are side benefits like a richer set of rubyspecs and sometimes fixes landing in MRI.
That was a great talk -- really sort of mind-warping to think that there are people working on "de-optimizing" the JVM so that Ruby can run faster in the average case.
I wouldn't say Facebook funds the development of PHP per se, but they do fund the development of HHVM and they made the initial draft of the language spec.
Yeah, I'd be interested too. I code PHP, Ruby, Python, C#, js and all of them have quirks and stuff. But Python and Ruby are almost identical other than some syntax sugar. PHP is PHP. $needle, $haystack gets me everytime. JS is just evil. Fucking hate that language. Dog turd. C# is nice, a bit verbose.
If he doesn't want to elucidate his point, its basically trolling, no matter what your experience. Its a line designed to draw a rise out of people - that's it.
More that Facebook's return on the amount of money they've spent on PHP is pretty poor.
Facebook has had the author of jemalloc locked up working on making PHP go faster for a few years now. Surely there's a more productive place to sink that kind of talent.
perhaps a bit of an exaggeration. i apologise. i suppose i'm mainly bitter about PHP. It completely baffles me that FB have invested so much money in the language ecosystem
It's too bad that keyword arguments are semantically opposite between CRuby and RubyMotion in Ruby 2.0+. It'll cause a divergence and makes it a little more difficult for Rails+RubyMotion engineers like me to switch.
I understand the reasoning behind both decisions (RubyMotion is following Objective-C's semantics, CRuby is following Python et al).
For those who aren't familiar with RubyMotion's syntax:
def my_method(arg1, keyword: arg2)
puts arg1
puts arg2
end
my_method("test", keyword: "test2")
# output
test
test2
Very misleading title. This is not about a GC speed up, it is about a reduction in pause time. The GC a itself is eating as many cycles as before (possibly more due to the cost of making things incremental) and they are clear about this in the article.
Even with a reasonable amount of Google-fu I can't find out how to track the development version of Ruby where these changes land with rbenv (I don't use RVM). Would some kind soul enlighten me?
53 comments
[ 4.4 ms ] story [ 113 ms ] threadNeed to hit vsync every 16ms? Just run a 1-3ms incremental GC every frame when you have time to spare, and as long as your game's theoretical performance is good enough, you won't ever hitch. This is one of Lua's advantages for game scripting because it's had a fairly solid incremental collector for a while, making it easy to give the GC a fixed chunk of time to operate in every frame so your game never pauses.
Scripting is a huge boon for people doing game development, game prototyping, and multimedia scripting (toolsets like Processing, for example), so having another scripting language to choose from for that is awesome.
IO/waiting for forked jobs can be done in background threads since the lock is released on some select function calls.
So while incremental GC certainly does bring down latency caused by the GC it does not bring down latency for tasks that could be parallelized.
The fact that those threads do not run in parallel is an entirely unrelated issue. Parallelism is not an essential quality of multi-threading.
Here's my basic understanding:
MRI is a single process, with multiple threads... They can't run in parallel because of the global interpreter lock (which is used because the code in MRI is not thread safe? Meaning each thread can touch the same memory and may leave it in a broken state for another thread, so we lock access to it first...).
So: there are multiple threads, I am guessing each with their own task (maybe one to run the code, one to do garbage collection, ... I have no idea), but because of the GIL they can't be parallelized. Still multi-threaded anyway.
What makes threads interesting is parallelism; if the goal is merely cooperative or pre-emptive multitasking, where there's no concurrency, then you're "effectively" not multi-threaded as per any modern expectation.
The answer is that it's often useful to manage multiple things at the same time, even if we can't or don't want to actually do them at the same time.
We may want to use blocking IO for the simplicity it gives us compared to asynchronous IO, but allow other parts of the system to continue to run during that blocking.
We may want to let threads and the kernel manage our context and context switches for us, instead of manually storing and restoring state, because it can be simpler that way.
They largely weren't. POSIX threads weren't standardized and widely adopted until the 90s, and it wasn't until multi-processor systems became more prevalent that threads saw wide adoption at all.
Having said that, GC improvements are a good thing. Some of the RPG Maker folks will be delighted when this eventually reaches them.
Is that a valid argument? IMO, keyword arguments are just making it explicit.
Well, you're trading connascence of position for connascence of name, which in this case is much better because you are providing context for the argument data.
[0]: https://blog.heroku.com/archives/2011/7/12/matz_joins_heroku
It's also worth noticing that another implementation, JRuby is supported by Redhat. IIRC 2 people work on it full-time: Charles Nutter (Headius) and Thomas Enebo
http://www.chrisseaton.com/rubytruffle/
Obviously, this isn't people being directly paid to work on MRI, but there are side benefits like a richer set of rubyspecs and sometimes fixes landing in MRI.
I don't think he's a troll; it just seems that his opinion of Ruby is influenced by experience in other languages.
Facebook has had the author of jemalloc locked up working on making PHP go faster for a few years now. Surely there's a more productive place to sink that kind of talent.
Hiring GvR is better than nothing, but still a very long way from a "deep-pocketed multinational funding Python development".
http://rubini.us/
I understand the reasoning behind both decisions (RubyMotion is following Objective-C's semantics, CRuby is following Python et al).
For those who aren't familiar with RubyMotion's syntax:
I wouldn't call an 81% reduction a 500% improvement.