Paruj Ratanaworabhan Kasetsart University, Thailand Ben Livshits and Ben Zorn Microsoft Research, Redmond JSMeter: Characterizing the Behavior of JavaScript.

Slides:



Advertisements
Similar presentations
An Implementation of Mostly- Copying GC on Ruby VM Tomoharu Ugawa The University of Electro-Communications, Japan.
Advertisements

Paging: Design Issues. Readings r Silbershatz et al: ,
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Goldilocks: Efficiently Computing the Happens-Before Relation Using Locksets Tayfun Elmas 1, Shaz Qadeer 2, Serdar Tasiran 1 1 Koç University, İstanbul,
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Nozzle: A Defense Against Heap Spraying Attacks Ben Livshits Paruj Ratanaworabhan Ben Zorn.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Introduction to Java Kiyeol Ryu Java Programming Language.
Nozzle: A Defense Against Heap-spraying Code Injection Attacks Paruj Ratanaworabhan, Cornell University Ben Livshits and Ben Zorn, Microsoft Research (Redmond,
An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.
Web Page Behavior IS 373—Web Standards Todd Will.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
Paruj Ratanaworabhan, Ben Livshits, and Ben Zorn JSMeter: Characterizing the Behavior of JavaScript Web Applications 1 In collaboration with David Simmons,
How to Build High Performing.NET Applications Vance Morrison.NET Performance Architect July 2009.
JSZap: Compressing JavaScript Code Martin Burtscher, UT Austin Ben Livshits & Ben Zorn, Microsoft Research Gaurav Sinha, IIT Kanpur.
JQuery CS 268. What is jQuery? From their web site:
4.1 JavaScript Introduction
Gulfstream Salvatore Guarnieri University of Washington Ben Livshits Microsoft Research Staged Static Analysis for Streaming JavaScript Applications.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Performance is Dead, Long Live Performance
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Paruj Ratanaworabhan Kasetsart University, Thailand Ben Livshits and Ben Zorn Microsoft Research, Redmond JSMeter: Characterizing the Behavior of JavaScript.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
Optimizing Marketing Spend Through Multi-Source Conversion Attribution David Jenkins.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Conrad Benham Java Opcode and Runtime Data Analysis By: Conrad Benham Supervisor: Professor Arthur Sale.
AjaxScope & Doloto: Towards Optimizing Client-side Web 2.0 App Performance Ben Livshits Microsoft Research (joint work with Emre.
Chapter 4 Memory Management Virtual Memory.
Introduction to Client Side Scripting CS Client Side Scripting Client side means the Browser is interpreting the script Script is downloaded with.
The Birth & Growth of Web 2.0 COM 415-Fall II Ashley Velasco (Prince)
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
1 Recursive Data Structure Profiling Easwaran Raman David I. August Princeton University.
An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning.
DynaRIA: a Tool for Ajax Web Application Comprehension Dipartimento di Informatica e Sistemistica University of Naples “Federico II”, Italy Domenico Amalfitano.
XP Tutorial 8 Adding Interactivity with ActionScript.

Lourie Lumb. Things you can do with Google Web Images Maps Videos News Shopping Gmail Finance Books Translate Google earth.
A Tour of Google Apps learn.cssd.ab.ca. Google Apps provide tools for creating, learning and sharing. Signing into your learn account gives you access.
Nozzle: A Defense Against Heap Spraying Attacks
1 Isolating Web Programs in Modern Browser Architectures CS6204: Cloud Environment Spring 2011.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Paruj Ratanaworabhan, Ben Livshits, David Simmons, and Ben Zorn JSMeter: Characterizing the Behavior of JavaScript Web Applications 1 In collaboration.
 An essential supporting structure of any thing  A Software Framework  Has layered structure ▪ What kind of functions and how they interrelate  Has.
SQL Unit Test Editor WinForm App T-SQL Script Dom Assemblies SQL Unit Test Framework Definition files for customization T-SQL from App SQL Profiler Trace.
Dynamic Parallelization of JavaScript Applications Using an Ultra-lightweight Speculation Mechanism ECE 751, Fall 2015 Peng Liu 1.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Web Analytics Fundamentals Presented by Tejaswi, Chandrika, Sunil.
Exposing Private Information by Timing Web Applications Stephen Kleinheider.
Best Institutes offering Software Development courses.
Section 10.1 Define scripting
Adobe Digital Marketing
Free SEO for Blogs & YouTube Channels.
More Security and Programming Language Work on SmartPhones
Challenges in Pointer Analysis of JavaScript
Doloto: Code Splitting for Web 2.0 Applications
John Bordsen Technology Trainer Gail Borden Public Library District
Runtime Analysis of Hotspot Java Virtual Machine
JavaScript an introduction.
Doloto: Code Splitting for Web 2.0 Applications
JavaScript.
Web Design and Development
Doloto: Code Splitting for AJAX Applications
Web Programming and Design
Web Application Development Using PHP
Exposing Private Information by Timing Web Applications
Presentation transcript:

Paruj Ratanaworabhan Kasetsart University, Thailand Ben Livshits and Ben Zorn Microsoft Research, Redmond JSMeter: Characterizing the Behavior of JavaScript Web Applications 1 in collaboration with David Simmons, Corneliu Barsan, and Allen Wirfs-Brock

One Word: 2 JavaScript Standard for scripting web applications Fast JITs widely available Support in every browser Lots of code present in all major web sites

Why Measure JavaScript? Standardized, de facto language for the web –Support in every browser, much existing code Benchmarks are driving browser marketing: “browser wars” –Are benchmarks representative? –Limited understanding of its behavior in real sites Who cares? –Users, web application developers, JavaScript engine developers 3

4 ZDNet 29 May 2008 ghacks.net Dec Browser Wars!

Artificial Benchmarks versus Real World Sites 5 Maps 7 V8 programs : richards deltablue crypto raytrace earley- boyer regexp splay 8 SunSpider programs: 3-draytrace access-nbody bitops-nsieve controlflow crypto-aes date-xparb math-cordic string-tagcloud JSMeter 11 real sites: Goals of this Talk Show behavior of JavaScript benchmarks versus real sites Consider how benchmarks can mislead design decisions Goals of this Talk Show behavior of JavaScript benchmarks versus real sites Consider how benchmarks can mislead design decisions

6 Instrumentation Framework \ie\jscript\*.cpp Source-level instrumentation custom jscript.dll custom trace files website visits Offline analyzers custom trace files

Visiting the Real Sites Getting past page load performance Attempted to use each site in “normal” way: 7 amazonSearch a book, add to shopping cart, sign in, and sign out bingType in a search query and also look for images and news bingmapSearch for a direction from one city to another cnnRead front page news ebaySearch for a notebook, bid, sing in, and sign out economistRead front page news, view comments facebookLog in, visit a friend pages, browse through photos and comments gmailSign in, check inbox, delete a mail, and sign out googleType in a search query and also look for images and news googlemapSearch for a direction from one city to another hotmailSign in, check inbox, delete a mail, and sign out

Understanding JavaScript Behavior CodeEvents JavaScript Objects 8

Code Behavior CodeEvents JavaScript Objects 9 Function size Instructions/call Code locality Instruction mix Function size Instructions/call Code locality Instruction mix

Total Bytes of JavaScript Source 10 Real Sites V8 SunSpider Code|Objects|Events

Ratio of Bytecode / Source 11 Real Sites V8 SunSpider Code|Objects|Events

Static Unique Functions Executed 12 Real Sites V8 SunSpider Code|Objects|Events

Total Bytecodes Executed Real Sites V8 SunSpider Code|Objects|Events

Total Function Calls 14 Real Sites V8 SunSpider Code|Objects|Events

Bytecodes / Call 15 function(a,b) { var i=0,elem,pos=a.length; if(D.browser.msie) { while(elem=b[i++]) if(elem.nodeType!=8) a[pos++]=elem; } else while(elem=b[i++]) a[pos++]=elem; return a } Real Sites V8 SunSpider Code|Objects|Events

Fraction of Code Executed 16 Most code not executed Real Sites V8 SunSpider Code|Objects|Events

Hot Function Distribution 17 Real SitesV8 Benchmarks 80% of time in < 10 functions80% of time in 100+ functions 80% Code|Objects|Events

Opcode Distribution 18 Green = SunSpider | Blue= Real Web Apps | Red = V8 Real Apps Outliers Code|Objects|Events

Object Allocation Behavior CodeEvents JavaScript Objects 19 Allocation by types Lifetime distribution Live heap composition Allocation by types Lifetime distribution Live heap composition

Total Bytes Allocated 20 Real Sites V8 SunSpider Code|Objects|Events

Heap Data by Type 21 Real Sites V8 SunSpider Many functions Rest are strings Few benchmarks allocate much data Code|Objects|Events

Object Type Distribution 22 Real Apps Code|Objects|Events economist is an outlier (arrays)

Live Heap Over Time (gmail) 23 Functions grow steadily Code|Objects|Events GC reduces size of heap Objects grow steadily too

Live Heap over Time (ebay) 24 Heaps repeatedly created, discarded Heap contains mostly functions Code|Objects|Events Heap drops to 0 on page load

2 Search Websites, 2 Architectures Bing (Web 2.0) Google (Web 1.0) Code|Objects|Events 25 You stay on the same page during your entire visit Code loaded once Heap is bigger Every transition loads a new page Code loaded repeatedly Heap is smaller

Two Mapping Websites 26 Bing Maps Google Maps Code|Objects|Events

Object Lifetimes (V8) 27 earley splay Code|Objects|Events Lives forever Dies immediately Lives until program ends

Object Lifetimes (gmail) 28 Strings are shortest lived Functions are longest lived Many objects live a major fraction of page lifetime This is as old as an object can be Code|Objects|Events

Event Handlers in JavaScript CodeEvents JavaScript Objects 29 Number of events Sizes of handlers Number of events Sizes of handlers

Event-driven Programming Model Single-threaded, non-preemptive event handlers Example handlers: onabort, onclick, etc. Very different from batch processing of benchmarks Handler responsiveness critical to user experience 30 Code|Objects|Events

Total Events Handled 31 Real Sites V8 Almost no events Code|Objects|Events

Average Bytecodes / Event Handled 32 Code|Objects|Events

Median Bytecodes / Event Handled 33 Code|Objects|Events

Maximum Bytecodes / Event Handled 34 Code|Objects|Events

Fraction of Execution in Handlers 35 Code|Objects|Events

Distribution of Time in Handlers 36 Code|Objects|Events

Cold-code Experiment Observation –Real web apps have lots of code (much of it cold) –Benchmarks do not Question: What happens if the benchmarks have more code? –We added extra, unused to code to 6 SunSpider benchmarks –We measured the impact on the benchmark performance 37

Performance Impact of Cold Code 38 ChromeIE 8 Cold code has non-uniform impact on execution time Without cold code, Chrome12x faster than IE8 With 2M cold code, Chrome 4.7x faster than IE8 Which comparison is more meaningful? Cold code makes SunSpider on Chrome up to 4.5x slower

Impact of Benchmarks What gets emphasis –Making tight loops fast –Optimizing small amounts of code Important issues ignored –Garbage collection (especially of strings) –Managing large amounts of code –Optimizing event handling –Considering JavaScript context between page loads 39

Conclusions JSmeter is an instrumentation framework –Used to measure and compare JavaScript applications –High-level views of behavior promote understanding Benchmarks differ significantly from real sites –Misleads designers, skews implementations Next steps –Develop and promote better benchmarks –Design and evaluate better JavaScript runtimes –Promote better performance tools for JavaScript developers 40

Conclusions JSmeter is an instrumentation framework –Used to measure and compare JavaScript applications –High-level views of behavior promote understanding Behavior in benchmarks significantly differs from real sites –Misleads designers, skews implementations Next steps –Develop and promote better benchmarks –Design and evaluate better JavaScript runtimes –Promote better performance tools for JavaScript developers 41

Additional Resources Project: Video: Project JSMeter: JavaScript Performance Analysis in the Real World" - MSDN Channel 9 interview with Erik Meier, Ben Livshits, and Ben ZornProject JSMeter: JavaScript Performance Analysis in the Real World Papers: –“JSMeter: Comparing the Behavior of JavaScript Benchmarks with Real Web Applications”, Paruj Ratanaworabhan, Benjamin Livshits and Benjamin G. Zorn, USENIX 2010 Conference on Web Application Development (WebApps’10), June –"JSMeter: Characterizing Real-World Behavior of JavaScript Programs", Paruj Ratanaworabhan, Benjamin Livshits, David Simmons, and Benjamin Zorn, MSR-TR , December 2009 (49 pages), November 2009."JSMeter: Characterizing Real-World Behavior of JavaScript Programs", 42

Additional Slides 43

Related Work JavaScript –“An Analysis of the Dynamic Behavior of JavaScript Programs”, Gregor Richards, Sylvain Lebresne, Brian Burg, Jan Vitek, PLDI 2010, June 2010/ C# and Java –Doufour C++ –Calder et al. 44