Code Monkey home page Code Monkey logo

Comments (10)

lautis avatar lautis commented on May 25, 2024

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.

from uglifier.

carlhoerberg avatar carlhoerberg commented on May 25, 2024
$ 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

from uglifier.

lautis avatar lautis commented on May 25, 2024

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

from uglifier.

carlhoerberg avatar carlhoerberg commented on May 25, 2024

#ExecJS::RubyRhinoRuntime:0x3710b205

On Wed, Dec 21, 2011 at 14:01, Ville Lautanala
[email protected]
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)

from uglifier.

lautis avatar lautis commented on May 25, 2024

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'?

from uglifier.

carlhoerberg avatar carlhoerberg commented on May 25, 2024

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
[email protected]
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)

from uglifier.

lautis avatar lautis commented on May 25, 2024

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.

from uglifier.

carlhoerberg avatar carlhoerberg commented on May 25, 2024

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

from uglifier.

lautis avatar lautis commented on May 25, 2024

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

from uglifier.

carlhoerberg avatar carlhoerberg commented on May 25, 2024

ok :)

from uglifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.