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

Run the compiler in-process on JRuby #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bbrowning
Copy link

The closure compiler runs significantly faster under JRuby when run
in-process versus shelling out. Behavior on non-JRuby runtimes remains
unchanged.

This was tested under JRuby 1.7.1 and Ruby 1.9.3 and passes all tests in both.

The closure compiler runs significantly faster under JRuby when run
in-process versus shelling out. Behavior on non-JRuby runtimes remains
unchanged.
@bbrowning
Copy link
Author

While there is a previous pull request to run this in-process on JRuby, it is outdated and did not pass all the tests. I took a slightly different approach to creating the in-process compiler so that argument parsing is all done in an identical way to the current command-line invocation and thus all tests pass.

@thejspr
Copy link

thejspr commented Apr 23, 2013

This PR fixes a current issue on Heroku where console logging gets included in the minifies javascript file. Specificly, if using JRuby, Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true gets inserted in the top of the JS file.

Anyone who needs this fix can temporarily use my updated fork at https://github.com/thejspr/closure-compiler/tree/jruby

@quadule
Copy link

quadule commented Jun 13, 2013

👍

@acds
Copy link

acds commented Sep 4, 2013

Hi @thejspr per your comment above, my code is pulling your fork from the git repository but I'm still getting the Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true in my javascript files.

I'm also running JRuby 1.7.4 in ruby 2.0.0 compatibility mode via JRUBY_OPTS: --2.0 -J-Xmx400m -J-XX:+UseCompressedOops -J-noverify

Is there anything else I need to do/configure to get the appropriate behavior.

As an aside for some reason the compilation also seems to be removing all the white-space that does not happen in application.js for example. This was happening anyway regardless of your fork.

Thanks !

@thejspr
Copy link

thejspr commented Sep 5, 2013

@acds I don't use ruby 2.0.0 compatibility mode, that might be an issue.

Are you using the correct branch? I.e.

  gem 'closure-compiler', github: 'thejspr/closure-compiler', branch: 'jruby'

@acds
Copy link

acds commented Sep 5, 2013

@thejspr Thanks so much for the response.

I'm forced into 2.00 compatibility due to some other dependencies. Agreeably being on the bleeding edge has its challenges. Especially as I'm somewhat new to all this, so please bear with me.

It seem that the asset pre-comple still takes absolutely ages.

It also seem to run though twice, Is this normal:

~ $ rake assets:precompile
Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
/app/jruby/bin/jruby ./bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
Compiled jquery.js  (64ms)  (pid 86)
Compiled jquery_ujs.js  (10ms)  (pid 86)
Compiled bootstrap-transition.js  (28ms)  (pid 86)
Compiled bootstrap-affix.js  (13ms)  (pid 86)
Compiled bootstrap-alert.js  (3ms)  (pid 86)
Compiled bootstrap-button.js  (22ms)  (pid 86)
Compiled bootstrap-carousel.js  (3ms)  (pid 86)
Compiled bootstrap-collapse.js  (3ms)  (pid 86)
Compiled bootstrap-dropdown.js  (3ms)  (pid 86)
Compiled bootstrap-modal.js  (3ms)  (pid 86)
Compiled bootstrap-scrollspy.js  (3ms)  (pid 86)
Compiled bootstrap-tab.js  (3ms)  (pid 86)
Compiled bootstrap-tooltip.js  (5ms)  (pid 86)
Compiled bootstrap-popover.js  (3ms)  (pid 86)
Compiled bootstrap-typeahead.js  (3ms)  (pid 86)
Compiled bootstrap.js  (1934ms)  (pid 86)
Compiled dashboard.js  (1ms)  (pid 86)
Compiled users.js  (3411ms)  (pid 86)
Compiled application.js  (6020ms)  (pid 86)
Compiled bootstrap_and_overrides.css  (56670ms)  (pid 86)
Compiled users.css  (131ms)  (pid 86)
Compiled application.css  (59936ms)  (pid 86)
Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
Compiled jquery.js  (177ms)  (pid 86)
Compiled jquery_ujs.js  (31ms)  (pid 86)
Compiled bootstrap-transition.js  (34ms)  (pid 86)
Compiled bootstrap-affix.js  (14ms)  (pid 86)
Compiled bootstrap-alert.js  (9ms)  (pid 86)
Compiled bootstrap-button.js  (14ms)  (pid 86)
Compiled bootstrap-carousel.js  (59ms)  (pid 86)
Compiled bootstrap-collapse.js  (29ms)  (pid 86)
Compiled bootstrap-dropdown.js  (30ms)  (pid 86)
Compiled bootstrap-modal.js  (4ms)  (pid 86)
Compiled bootstrap-scrollspy.js  (9ms)  (pid 86)
Compiled bootstrap-tab.js  (14ms)  (pid 86)
Compiled bootstrap-tooltip.js  (3ms)  (pid 86)
Compiled bootstrap-popover.js  (13ms)  (pid 86)
Compiled bootstrap-typeahead.js  (5ms)  (pid 86)
Compiled bootstrap.js  (3653ms)  (pid 86)
Compiled dashboard.js  (13ms)  (pid 86)
Compiled users.js  (16573ms)  (pid 86)
Compiled application.js  (22017ms)  (pid 86)
Compiled bootstrap_and_overrides.css  (17364ms)  (pid 86)
Compiled users.css  (15ms)  (pid 86)
Compiled application.css  (18302ms)  (pid 86)
~ $ 

and an I often get two Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true warnings in a row.

2013-09-05T19:48:07.001961+00:00 heroku[web.1]: Starting process with command `bundle exec puma -p 50229 -C ./config/puma.rb`
2013-09-05T19:48:08.011377+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
2013-09-05T19:48:22.519946+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
2013-09-05T19:48:36.304577+00:00 app[web.1]: The signal USR1 is in use by the JVM and will not work correctly on this platform
2013-09-05T19:48:36.305877+00:00 app[web.1]: Puma starting in single mode...
2013-09-05T19:48:36.306002+00:00 app[web.1]: * Version 2.5.1, codename: Astronaut Shoelaces
2013-09-05T19:48:36.306171+00:00 app[web.1]: * Min threads: 0, max threads: 5
2013-09-05T19:48:36.306296+00:00 app[web.1]: * Environment: production
2013-09-05T19:48:55.414520+00:00 app[web.1]: * Listening on tcp://0.0.0.0:50229
2013-09-05T19:48:55.448088+00:00 app[web.1]: Use Ctrl-C to stop
2013-09-05T19:48:55.592126+00:00 heroku[web.1]: State changed from starting to up

However I's still running into asset problems:

2013-09-05T19:51:20.259553+00:00 app[web.1]: Started GET "/" for 50.174.65.141 at 2013-09-05 19:51:20 +0000
2013-09-05T19:51:20.341199+00:00 app[web.1]: Processing by HomeController#index as HTML
2013-09-05T19:51:20.731729+00:00 app[web.1]: Compiled dashboard.js  (112ms)  (pid 2)
2013-09-05T19:51:31.471892+00:00 app[web.1]:   Rendered home/index.html.erb within layouts/application (11020.0ms)
2013-09-05T19:51:31.914825+00:00 app[web.1]: WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
2013-09-05T19:51:35.302016+00:00 app[web.1]: Completed 500 Internal Server Error in 14960ms
2013-09-05T19:51:35.527258+00:00 app[web.1]: 
2013-09-05T19:51:35.527258+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2013-09-05T19:51:35.527258+00:00 app[web.1]: Load path: /app
2013-09-05T19:51:35.527258+00:00 app[web.1]:   (in /app/app/assets/stylesheets/bootstrap_and_overrides.css.scss)):
2013-09-05T19:51:35.527258+00:00 app[web.1]:     4:     <meta name="viewport" content="width=device-width, initial-scale=1.0">
2013-09-05T19:51:35.527258+00:00 app[web.1]:     5:     <title><%= content_for?(:title) ? yield(:title) : "XXXXXXX" %></title>
2013-09-05T19:51:35.527258+00:00 app[web.1]:     6:     <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "XXXXX" %>">
2013-09-05T19:51:35.527258+00:00 app[web.1]:     7:     <%= stylesheet_link_tag "application", :media => "all" %>
2013-09-05T19:51:35.527258+00:00 app[web.1]:     8:     <%= javascript_include_tag "application" %>
2013-09-05T19:51:35.527258+00:00 app[web.1]:     9:     <%= csrf_meta_tags %>
2013-09-05T19:51:35.527480+00:00 app[web.1]:     10:     <%= yield(:head) %>
2013-09-05T19:51:35.527480+00:00 app[web.1]:   app/assets/stylesheets/bootstrap_and_overrides.css.scss:1
2013-09-05T19:51:35.527480+00:00 app[web.1]:   app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__856202050_19212'
2013-09-05T19:51:35.527480+00:00 app[web.1]: 
2013-09-05T19:51:35.527480+00:00 app[web.1]: 

Any Thoughts? All works great in development!

@thejspr
Copy link

thejspr commented Sep 6, 2013

I think it's normal that it runs the compilation twice, at least my deploy works like that as well. You shouldn't worry about the Picked up JAVA_TOOL... messages, unless they break anything of course, it's just the JVM being noisy. I don't know why your assets aren't working though

@shepmaster
Copy link

👍 to the original PR. Is there anything that we can do to help get this merged in?

@shepmaster
Copy link

For what it's worth, this sped up our asset precompile from 2:30 to about 2:00.

@alex88
Copy link

alex88 commented Dec 13, 2013

Any chance to get this merged?

@calebjclark
Copy link

+1

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

Successfully merging this pull request may close these issues.

7 participants