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

Doesn't work with jruby x64 #22

Closed
carlhoerberg opened this issue Dec 21, 2011 · 10 comments
Closed

Doesn't work with jruby x64 #22

carlhoerberg opened this issue Dec 21, 2011 · 10 comments

Comments

@carlhoerberg
Copy link

https://gist.github.com/1503754

@lautis
Copy link
Owner

lautis commented Dec 21, 2011

What JS runtime are you using? Tests pass with therubyrhino and jruby 1.6.5 (Travis CI, other libraries use C-extensions which are known to have problems on JRuby.

@carlhoerberg
Copy link
Author

$ jruby -v
jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]

gives

$ jruby -e "require 'uglifier'; Uglifier.compile File.read 'jquery-1.7.1.js'"
java(25487,0x10f18a000) malloc: *** error for object 0x7f9604a05300: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

@lautis
Copy link
Owner

lautis commented Dec 21, 2011

What does jruby -e "require 'uglifier'; puts ExecJS.runtime say? You might also want to try EXECJS_RUNTIME =RubyRhino jruby -e "require 'uglifier' …"

@carlhoerberg
Copy link
Author

#ExecJS::RubyRhinoRuntime:0x3710b205

On Wed, Dec 21, 2011 at 14:01, Ville Lautanala
reply@reply.github.com
wrote:

What does jruby -e "require 'uglifier'; puts ExecJS.runtime say? You might also want to try EXECJS_RUNTIME =RubyRhino jruby -e "require 'uglifier' …"


Reply to this email directly or view it on GitHub:
#22 (comment)

@lautis
Copy link
Owner

lautis commented Dec 21, 2011

I can't replicate this with jruby 1.6.5 (running in 1.9 mode on same 64bit jvm).

Can you run anything with ExecJS? E.g. ExecJS.eval '1+1'?

@carlhoerberg
Copy link
Author

indeed and uglifier works for very small files as well, but not with
for example jquery (http://code.jquery.com/jquery-1.7.1.js)

On Wed, Dec 21, 2011 at 14:21, Ville Lautanala
reply@reply.github.com
wrote:

I can't replicate this with jruby 1.6.5 (running in 1.9 mode on same 64bit jvm).

Can you run anything with ExecJS? E.g. `ExecJS.eval '1+1'?


Reply to this email directly or view it on GitHub:
#22 (comment)

@lautis
Copy link
Owner

lautis commented Dec 21, 2011

I managed to replicate the segfault with yajl-ruby gem. It uses C extensions, which AFAIK are still experimental in JRuby.

Uglifier uses multi_json, which tries to load the best available JSON parser. You can manually change the used engine to something which works on your platform with MultiJson.engine = :json_gem or just remove yajl-ruby from your Gemfile/system.

@lautis lautis closed this as completed Dec 21, 2011
@carlhoerberg
Copy link
Author

ok, thanks! no seg fault, but still very slow..

$ jruby -b -e "require 'uglifier'; Uglifier.compile File.read 'jquery-1.7.1.js'"
Runtime: 62870 ms

$ jruby -b -e "require 'closure-compiler'; Closure::Compiler.new.compress File.read 'jquery-1.7.1.js'"
Runtime: 11416 ms

with ruby 1.9.3

$ time ruby -e "require 'uglifier'; Uglifier.compile File.read 'jquery-1.7.1.js'"
real    0m2.863s
user    0m2.598s
sys 0m0.122s

$ time ruby -e "require 'closure-compiler'; Closure::Compiler.new.compress File.read 'jquery-1.7.1.js'"
real    0m8.992s
user    0m22.781s
sys 0m0.598s

@lautis
Copy link
Owner

lautis commented Dec 21, 2011

Yeah. Especially the first run with fresh jvm is extremely slow with RubyRhino. Using V8/Node.js runtime makes Uglifier much faster, but it requires you to have node in your PATH and forcing ExecJS to use Node (ExecJS.runtime = ExecJS::Runtimes::Node)

Quick runs with benchmark:

RubyRhino Cold JVM: 55.332000s
RubyRhino Second run: 21.028000s
Node: 3.539000s

@carlhoerberg
Copy link
Author

ok :)

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

2 participants