Since adding observers to my Ruby module, my system locks up - ruby

It only happens on certain types of errors, for example if I make a call to a method that doesn't exist on one of my objects. But it's hard to get any information on what is causing this because I can't step through what is causing it, as my debugger locks up as well. When I look at top, I see something like 97% of my CPU time being taken up by a Ruby process. I tried running Sample Process in activity monitor to see if it could show me where it is getting stuck, but nothing relevant seems to come up (just alot of OSX classes).
This is a Padrino project, I am running Ruby 1.9.2 and using the Observable mixin. I am on OSX Lion. Any ideas or suggestions for troubleshooting? This is killing my productivity!!

Which version of padrino do you have? Latest 0.10.1 fix this problem.

Related

Ruby Continuation-heavy application SLOW

I'm trying to run a Continuation-heavy project in Ruby, and it's terribly slow... I even tried to insert GC.start lines at key points in the code to speed things up, assuming memory was clogged up, and that's didn't help. I tried running Maglev but I use too many gems that are incompatible with it.
Any ideas?

Does puma work or Windows or not?

I've been trying for several days now, but I always come back to the two links that tell me conflicting information. This link says that I just need backports to get puma to work (anything beyond simply installing, I can't seem to find either.) And this link suggests the complete opposite, that puma will not work on windows. And, yet again, here it looks like it does work if you do something. I'm not sure what to believe, or what processes to take to get puma working, if it does work on windows.
For anyone interested in my personal problem, if it can be solved, is that puma throws the same errors based on SIGUSR NOT IMPLIMENTED signal based restart unavailable. I've installed backports, but that alone doesn't fix it. What am I missing, besides this?
EDIT: Somehow I got everything but SIGUSR2 to work. I'd call that an achievement, except I'm not sure how I did it besides changing versions and reinstalling puma and backports several times.

Ruby/Tk in a browser

Is there a quick and easy way to make a ruby/Tk script run in a browser? I wrote a handy-dandy little ruby/tk script to do stuff. A friend saw it and said that his friends would love to use it, but they are extremely non-technical and cannot handle installing ruby (even though I showed him how simple it is). What he wants is for me to give him a link that someone can click on a browser and magically make the tool run.
I've looked around and get the impression that it cannot be done. 'it just does not work that way'. But I have not seen a clear 'NO' . I see things on how to get ruby to run in a browser, but not the Tk part. I also looked at rubyscript2exe but get the impression that it was abandoned.
No, you can't directly run Ruby in the browser like that.
There are websites such as RubyFiddle which let you run short snippets. What they're actually doing is executing the code remotely then displaying the result.
Because this code is actually being executed remotely, there's no way of running something interactive (like a TK UI) with it. There are some services which give you a hosted Ruby environment with working Terminal, but even these aren't going to work with a TK UI.
This section of Ruby Gems https://www.ruby-toolbox.com/categories/packaging_to_executables has a good list of all the tools available to package Ruby apps for distribution though, so you might be able to send them a simple installer to allow them to use it locally?
I've had a lot of success doing this with https://github.com/larsch/ocra/ which is actively maintained.

How to profile garbage collection in Ruby

I'm trying to profile GC in a non-Rails application, preferably using YARV Ruby.
perftools.rb is telling me that the majority of my CPU time is spent in garbage_collector (6061 (61.4%)).
I'm also able to get how many objects are created by which methods with perftools.rb . Some methods create more objects than others, but it's not extremely skewed.
Where do I go from here? Is it possible to get more detailed information on why it's spending so much time doing GC? Is it possible to see whether the time is spent getting rid of objects, or whether it is spent checking whether an object should be garbage collected or not?
I have access to OS X Lion, Windows 7 and Ubuntu 12.04.
On osx you have dtrace. There are dtrace providers in YARV ruby.
You have a couple of probes related to GC that you can use:
gc-begin
gc-end
gc-mark-begin
gc-mark-end
gc-sweep-begin
gc-sweep-end
I think they can help finding what the GC in your program is doing. have a look at this file to see how use them: https://github.com/tenderlove/ruby/blob/probes/test/dtrace/test_gc.rb.
And this post for more explanations: http://tenderlovemaking.com/2011/06/29/i-want-dtrace-probes-in-ruby.html
There's a bug opened in ruby http://bugs.ruby-lang.org/issues/2565 where you can find a patch to apply to ruby to have those probes or you can use https://github.com/tenderlove/ruby/tree/probes where the patch is already applied.
Hope this helps

How would you go about making an online IRB that runs in the browser

Im wondering how to go about creating an online IRB that runs in the browser. I have an idea to include an irb console in my blog and give the option for users to send code blocks in my tutorials directly into the irb console so they can play around with it.
_Why did this previously, but of course it is gone now: Cached Version
TryRuby is still available here, with source code at GitHub.
Well, you could use the sandbox that _why created. But you'll need to be able to patch your ruby and it seems to only work on ruby 1.8.5 .
That's insanely dangerous. Don't do this. You expose your system to all sorts of vulnerabilities when you allow users to execute arbitrary Ruby code.
Anyway there are some client-side Ruby implementations in JavaScript/Flash. Take a look at HotRuby.
I would suspect you run Ruby in a sandbox to prevent "bad" commands being run.

Resources