Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak ENV vars for optimal JRuby performance #93

Closed
myronmarston opened this issue Dec 2, 2011 · 10 comments
Closed

Tweak ENV vars for optimal JRuby performance #93

myronmarston opened this issue Dec 2, 2011 · 10 comments

Comments

@myronmarston
Copy link

As most people know, JRuby suffers from slow startup times even though it performs very well over the lifetime of a long-lived process. Unfortunately, when you use aruba to test a command line tool on multiple ruby interpreters, including JRuby, you wind up with really, really slow performance on JRuby since the startup times are so bad and aruba is constantly shelling out to create new jruby processes.

There are a few ENV vars that most people aren't aware of that make a big difference:

  • JRUBY_OPTS=-X-C disables the JIT, which is good for short lived scripts
  • JAVA_OPTS=-d32 forces it to use the client JVM which has better startup times than the server JVM

I got both of these settings from this blog post for those who are interested.

I just set these variables for rspec-core and it cut 10 minutes off of the build time. It allows us to build rspec-core on travis using JRuby.

We can change this for all the other rspec repos as well...but it got me thinking: why not put these settings directly into aruba itself? Not many people know about them, and given the short-lived nature of the processes aruba starts, I can't imagine a time when you wouldn't want them.

Thoughts?

@mattwynne
Copy link
Member

That sounds useful. Any thoughts on where they should go in the code?

@myronmarston
Copy link
Author

Maybe create a set_env_defaults method can call it from the start of #run? If the set_env_defaults method only set JAVA_OPTS or JRUBY_OPTS if they are not already set then it would give end-users a chance to use set_env to set these to something else if they want.

@mattwynne
Copy link
Member

Sounds reasonable. Or how about if we provide a hook, something like this:

Aruba.configure do |config|
  config.before_run do
    ENV['JAVA_OPTS'] = '-X-C'
    # ...
  end
end

That way you could keep this stuff tucked away in a file of it's own (still inside aruba's source, required by default). WDYT?

That

@myronmarston
Copy link
Author

That seems reasonable.

mattwynne added a commit that referenced this issue Dec 2, 2011
@mattwynne
Copy link
Member

@myronmarston let me know what you think of the code in that branch and if it's good I'll merge it in.

mattwynne added a commit that referenced this issue Dec 5, 2011
@mattwynne
Copy link
Member

Merged into master

@mattwynne
Copy link
Member

(Thanks @myronmarston)

@alindeman
Copy link

@myronmarston, @mattwynne: What do you think about merging any currently setup ENV['JRUBY_OPTS']? For instance, if the parent process were started with JRUBY_OPTS="--1.9", it'd be nice if that trickled down into the child process. Thoughts?

@myronmarston
Copy link
Author

@alindeman that makes sense to me, if that's not already the behavior. This issue was a while ago so I had mostly forgotten about it.

@alindeman
Copy link

Gotcha! I ran into it while trying to test rspec under jruby-19mode. In JRuby 1.6, you pass JRUBY_OPTS="--1.9", but this setting wasn't being passed to subprocesses ... so they'd start in 1.8 mode, failing version-specific tests.

Pull request is #125.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants