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

Performance decrease / memory usage increase between 1.7 and 9.1 #4012

Open
estolfo opened this issue Jul 12, 2016 · 3 comments
Open

Performance decrease / memory usage increase between 1.7 and 9.1 #4012

estolfo opened this issue Jul 12, 2016 · 3 comments

Comments

@estolfo
Copy link

estolfo commented Jul 12, 2016

I've noticed the performance of the Ruby driver and Mongoid's test suites decreasing with JRuby versions following 1.7 and am looking for ideas on how to investigate.

The Ruby driver's test suite on travis can be seen here.

  • The test suite runs in 1 - 2 minutes on MRI (performance is not hugely different between MRI versions)
  • JRuby 1.7: takes from 3 - 4 minutes
  • JRuby 9.1.2.0: it takes from 7 - 10 minutes

Mongoid's test suite shows the same trend but uses a lot of memory on JRuby 9.1.2.0. I have a branch for testing Mongoid on JRuby and comparing the performance to MRI here

  • I've set the jruby-openssl gem version to 0.9.17 on that branch, so this issue doesn't seem to be the culprit.
  • The branch has the JRUBY_OPTS Xmx-- setting at 1G

While I can continue to increase the limit until the process doesn't run out of memory, the performance is surprising. I've done some profiling on some of the most common Model methods in Mongoid but haven't found any valuable information yet.

I'd welcome any ideas you might have, thanks!

@kares
Copy link
Member

kares commented Jul 13, 2016

test performance is tricky ... 9K might need more memory, which in cases such as bounded envs (travis-ci) might trigger a lot of GC if its low. did you try reproducing locally ?

tips for improving test time :

  • export JRUBY_OPTS="--dev"
  • avoid bundle exec rake spec:ci (e.g. ruby -rbundler/setup -S rake spec:ci) less JVMs
  • or set the initial JVM memory reasonably low -Xmn (to have more mem for 'main' JVM process)

@headius
Copy link
Member

headius commented Jul 13, 2016

@estolfo Does the test suite run a lot of subprocesses? If so, that could explain this. JRuby 9k starts up a bit slower than 1.7, mostly because of the additional boot logic needed for 2.3 (new gems, etc).

I've been working on a page to document tips for improving performance here: https://github.com/jruby/jruby/wiki/Troubleshooting-Performance

Given that 9k uses a lot more memory, that may be where we want to look. However it runs extremely slow using the flag on the page above. If I can get the suite to run locally, I could try to do a lighter-weight allocation profile.

@estolfo
Copy link
Author

estolfo commented Jul 14, 2016

Hi @headius

It doesn't run a lot of subprocesses. I'm sure being able to test it out locally would be helpful:

prerequisites for both testing mongoid and the driver:

  1. install mongodb, using brew, for example, or download here
  2. start mongod on the default host and port: mongod

Clone the driver and run the tests:

  1. You can clone the ruby driver:
    • git clone git@github.com:mongodb/mongo-ruby-driver.git
    • cd mongo-ruby-driver
  2. run bundle
    • bundle
  3. Run the test suite:
    • bundle exec rake spec

Clone mongoid and run the tests:

  1. You can clone mongoid:
    • git clone git@github.com:mongodb/mongoid.git
    • cd mongoid
  2. run bundle
    • bundle
  3. Run the test suite:
    • bundle exec rake spec

I'll do some profiling today and let you know if I find anything worth mentioning.
Thanks so much for your help!

Emily

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