Js engine performance
Upcoming SlideShare
Loading in...5
×
 

Js engine performance

on

  • 4,922 views

 

Statistics

Views

Total Views
4,922
Views on SlideShare
4,727
Embed Views
195

Actions

Likes
1
Downloads
47
Comments
0

21 Embeds 195

http://jsengineperformance.blogspot.com 113
http://jsengineperformance.blogspot.ca 14
http://jsengineperformance.blogspot.ru 13
http://jsengineperformance.blogspot.co.uk 10
http://jsengineperformance.blogspot.de 8
http://jsengineperformance.blogspot.fr 5
http://jsengineperformance.blogspot.it 5
http://jsengineperformance.blogspot.in 4
http://jsengineperformance.blogspot.kr 3
http://jsengineperformance.blogspot.se 3
http://jsengineperformance.blogspot.ro 3
http://jsengineperformance.blogspot.nl 2
http://jsengineperformance.blogspot.pt 2
http://jsengineperformance.blogspot.jp 2
http://jsengineperformance.blogspot.hu 2
http://jsengineperformance.blogspot.com.ar 1
http://jsengineperformance.blogspot.com.br 1
http://jsengineperformance.blogspot.gr 1
http://jsengineperformance.blogspot.com.au 1
http://jsengineperformance.blogspot.com.es 1
http://jsengineperformance.blogspot.no 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Js engine performance Js engine performance Presentation Transcript

  • JS Engine Performance Scutariu Paul Stirban Ionut 1
  • Table of contents1. Introduction2. V8 engine – Google Chrome 163. SpiderMonkey - FireFox 94. Chakra – IE 95. Carakan – Opera 116. Case study – Chrome vs FireFox vs IE vs Opera7. Bibliography 2
  • Introduction■ The performance of javascript engine is an important feature of aweb browser when developing a client web application.■ The user will obvious be more satisfied if some elements of theapplication are working better. In that case he may use thatbrowser where the javascript engine is much faster■ By far, v8 engine used by google is faster than other browsers likeFireFox, IE 9 or Opera. This will be shown is the last chapter at casestudy■ So, regarding these, we will talk about in this presentation aboutthe improvements of all these engines . Also the statistics at the endof presentation will show the results of every engine 3
  • V8 Engine – Google Chrome 1■ V8 is Googles open source JavaScript engine■ V8 is written in C++ and is used in Google Chrome, the opensource browser from Google■ V8 can run standalone, or can be embedded into any C++application■ V8 increases performance by compiling JavaScript to nativemachine code before executing it, rather than to execute bytecodeor interpreting it. Further performance increases are acheived byemploying optimization techniques such as inline caching■ With these features, JavaScript applications running within V8 aresaid to have an effective speed comparable to a compiled binary 4
  • V8 Engine – Google Chrome 2Improvements:1. fast property access + hidden classesfunction Point(x,y){ this.x = x; this.y = y;}var p1 = new Point(1,2);var p2 = new Point(2,3);- most JavaScript engines would store p1 and p2 like they don’tbelong to the same class, but in v8 p1 and p2 shares the samehidden class.2. Dynamic machine code generation- javascript source code is compiled into machine code when firstexecution occurs. 5
  • V8 Engine – Google Chrome 3Improvements:3. Garbage collectorv8 engine:- stops program execution when performing a garbage collectioncycle.- processes only part of the object heap in most garbage collectioncycles. This minimizes the impact of stopping the application.- always knows exactly where all objects and pointers are inmemory. This avoids falsely identifying objects as pointers which canresult in memory leaks.http://code.google.com/apis/v8/design.htmlhttp://en.wikipedia.org/wiki/Inline_caching 6
  • SpiderMonkey – FireFox 9 1■ SpiderMonkey: 30% faster■ SpiderMonkey integrates type inference with Jaegermonkey JITcompiler to generate efficient code■ SpiderMonkey is written in C++ and contains an interpreter,several JIT compilers (TraceMonkey, JägerMonkey, and IonMonkey),a decompiler, and a garbage collector. 7
  • SpiderMonkey – FireFox 9 2TraceMonkey- TraceMonkey is the first JIT compiler written for the JavaScriptlanguage- The compiler was first released as part of SpiderMonkey in Firefox3.5, providing "performance improvements ranging between 20 and40 times faster" than the baseline interpreter in Firefox 3- Instead of compiling whole functions, TraceMonkey operates byrecording control flow and data types during interpreter execution.This data then informs the construction of Trace Trees, highlyspecialized paths of native code 8
  • SpiderMonkey – FireFox 9 3JägerMonkey- JägerMonkey, internally named MethodJIT, is a whole-method JITcompiler designed to improve performance in cases whereTraceMonkey cannot generate stable native code.- JägerMonkey operates very differently from other compilers in itsclass: while typical compilers work by constructing and optimizinga control flow graph representing the function, JägerMonkeyinstead operates by iterating linearly forward throughSpiderMonkey bytecode, the internal function representation.Although this prohibits optimizations that require instructionreordering, JägerMonkey compilation has the advantage of beingextremely fast, which is useful for JavaScript since recompilation dueto changing variable types is frequent 9
  • SpiderMonkey – FireFox 9 4JägerMonkey Mozilla implemented a number of critical optimizations inJägerMonkey, most importantly Polymorphic Inline Caches andType inferencehttp://en.wikipedia.org/wiki/Type_inferenceIonMonkey IonMonkey is a compiler in the traditional sense: it translatesSpiderMonkey bytecode into a control flow graph, using SSA for theintermediate representation. This architecture enables well-knownoptimizations from other programming languages to be used forJavaScript, including type specialization, function inlining, linear-scan register allocation, dead code elimination, and loop-invariantcode motion 10
  • Chakra – IE 9 1■ Chakra is the new JScript engine developed by Microsoft for theirupcoming Internet Explorer 9 (IE9) web browser■ A distinctive feature of the engine is that it compiles scripts on aseparate CPU core, parallel to the web browser■ Chakra improves the performance of the browser and the webpages render and respond much faster 11
  • Chakra – IE 9 2■ Chakra, fundamentally changes the performance characteristicsof JavaScript inside Internet Explorer 9. Chakra includes a newJavaScript compiler that compiles JavaScript source code into high-quality native machine code, a new interpreter for executing scripton traditional web pages, and improvements to the JavaScriptruntime and libraries. You can read more details on Chakraat TechNet. 12
  • Carakan – Opera 11 1■ So how fast is Carakan? Using a regular cross-platform switchdispatch mechanism (without any generated native code) Carakanis currently about two and a half times faster at the SunSpiderbenchmark than the ECMAScript engine in Presto 2.2 (Opera 10Alpha). Since Opera is ported to many different hardwarearchitectures, this cross-platform improvement is on its own veryimportant■ The native code generation in Carakan is not yet ready for full-scale testing, but the few individual benchmark tests that it isalready compatible with runs between 5 and 50 times faster, so it islooking promising so far 13
  • Carakan – Opera 11 2Improvements:1. Automatic object classification- A major improvement over this engine is in the representation of ECMAScript objects. Each object is assigned a class that collects various information about the object, such as its prototype and the order and names of some or all of its properties- Class assignment is naturally very dynamic, since ECMAScript is a very dynamic language, but it is organized such that objects with the same prototype and the same set of properties are assigned the same class 14
  • Carakan – Opera 11 3Improvements:1. Automatic object classification- This representation allows compact storage of individual objects, since most of the complicated structures representing the objects properties are stored in the class, where they are shared with all other objects with the same class. In real-world programs with many objects of the same classes, this can save significant amounts of memory.- For two objects with the same class, if the lookup of a property "X" on the first object gave the result Y, we know that the same lookup on the second object will also give the result Y. We use this to cache the result of individual property lookups in ECMAScript programs, which greatly speeds up code that contains many property reads or writes 15
  • Carakan – Opera 11 4Improvements:2. Native code generation- Although engines bytecode instruction set permits theimplementation of a significantly faster bytecode execution engine,there is still significant overhead involved in executing simpleECMAScript code, such as loops performing integer arithmetics, in abytecode interpreter.- In addition to generating native code from regular ECMAScriptcode, we also generate native code that performs the matching ofsimple regular expressions. This improves performance a lot whensearching for matches of simple regular expressions in long strings.For sufficiently long strings, this actually makes searching for asubstring using a regular expression faster than the same searchusing String.prototype.indexOf. For shorter strings, the speed is limitedby the overhead of compiling the regular expression 16
  • Carakan – Opera 11 5Improvements:3. Register-based bytecode- The last couple of generations of Operas ECMAScript engine haveused a stack-based bytecode instruction set. This type of instructionset is based around a stack of values, where most instructions "pop"input operands from the value stack, process them, and "push" theresult back onto the value stack. Some instructions simply pushvalues onto the value stack, and others rearrange the values on thestack. This gives compact bytecode programs and is easy togenerate bytecode for 17
  • Case study – Chrome vs FireFox vs IE vs Opera 1Now we will se some performance statistics using v8 and krakenbenchmarks.V8 benchmark:http://v8.googlecode.com/svn/data/benchmarks/v5/run Score 2500 2000 1500 1000 2085 1354 500 959 629 0 IE 9 Opera 11.6 FireFox 9 Chrome 16 18
  • Case study – Chrome vs FireFox vs IE vs Opera 2Now we will se some performance statistics using v8 and krakenbenchmarks.V8 benchmark:http://v8.googlecode.com/svn/data/benchmarks/v5/run Browser Speed Google Chrome 16 2085 ms Opera 11.6 959 ms FireFox 9 1354 ms IE 9 629 ms The biggest score indicates the browser’s engine with the best performance 19
  • Case study – Chrome vs FireFox vs IE vs Opera 3Now we will se some performance statistics using v8 and krakenbenchmarks.Kraken benchmark:http://krakenbenchmark.mozilla.org/ Time in milliseconds 60000 50000 40000 30000 55878 20000 42685 10000 13399 15315.4 0 Chrome 16 FireFox 9 Opera 11.6 IE 9 20
  • Case study – Chrome vs FireFox vs IE vs Opera 4Now we will se some performance statistics using v8 and krakenbenchmarks.Kraken benchmark:http://krakenbenchmark.mozilla.org/ Browser Speed Google Chrome 16 13399.3ms +/- 1.8% FireFox 9 15315.4ms +/- 0.6% Opera 11.6 42685.0ms +/- 1.2% IE 9 55878.0ms +/- 1.8% Now time is being calculated in miliseconds and obvious the lowest is the best engine As we can see, Google’s v8 is the best engine by far, and the statistics show this. 21
  • Bibliographyhttp://code.google.com/apis/v8/design.htmlhttp://blog.mozilla.com/blog/2011/12/20/major-javascript-enhancements-make-firefox-speedy-up-to-30-faster/http://my.opera.com/core/blog/2009/02/04/carakanhttp://www.thewindowsclub.com/microsofts-new-javascript-engine-codenamed-chakra-for-internet-explorer-9http://en.wikipedia.org/wiki/SpiderMonkey_(JavaScript_engine)http://en.wikipedia.org/wiki/V8_(JavaScript_engine) 22