JSZap: Compressing JavaScript Code Martin Burtscher, UT Austin Ben Livshits & Ben Zorn, Microsoft Research Gaurav Sinha, IIT Kanpur.

Slides:



Advertisements
Similar presentations
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advertisements

1 Chapter 4:Constraint Logic Programs Where we learn about the only programming concept rules, and how programs execute.
Java Script Session1 INTRODUCTION.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Shared-Dictionary Compression over HTTP (SDCH)‏ Wei-Hsin Lee June 2008.
Greedy Algorithms (Huffman Coding)
S ECURING WEB 2.0 APPLICATIONS THROUGH REPLICATED EXECUTION Ben Livshits Microsoft Research K. Vikram Cornell University Abhishek Prateek IIT Delhi.
Ben Livshits and Emre Kiciman Microsoft Research Redmond, WA.
A Data Compression Algorithm: Huffman Compression
Performance Evaluation of IPv6 Packet Classification with Caching Author: Kai-Yuan Ho, Yaw-Chung Chen Publisher: ChinaCom 2008 Presenter: Chen-Yu Chaug.
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
Using Redundancy and Interleaving to Ameliorate the Effects of Packet Loss in a Video Stream Yali Zhu, Mark Claypool and Yanlin Liu Department of Computer.
A Tool for Describing and Evaluating Hierarchical Real-Time Bus Scheduling Policies Author: Trevor Meyerowitz, Claudio Pinello, Alberto DAC2003, June 24,2003.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
JavaScript Demo Presented by … Jaisingh Sumit jain Sudhindra Taran Deep arora.
VPC3: A Fast and Effective Trace-Compression Algorithm Martin Burtscher.
By Ravi Shankar Dubasi Sivani Kavuri A Popularity-Based Prediction Model for Web Prefetching.
Gulfstream Salvatore Guarnieri University of Washington Ben Livshits Microsoft Research Staged Static Analysis for Streaming JavaScript Applications.
New Protocols for Remote File Synchronization Based on Erasure Codes Utku Irmak Svilen Mihaylov Torsten Suel Polytechnic University.
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
High Throughput Compression of Double-Precision Floating-Point Data Martin Burtscher and Paruj Ratanaworabhan School of Electrical and Computer Engineering.
VEX: VETTING BROWSER EXTENSIONS FOR SECURITY VULNERABILITIES XIANG PAN.
GFPC: A Self-Tuning Compression Algorithm Martin Burtscher 1 and Paruj Ratanaworabhan 2 1 The University of Texas at Austin 2 Kasetsart University.
Secure Web Applications via Automatic Partitioning Stephen Chong, Jed Liu, Andrew C. Meyers, Xin Qi, K. Vikram, Lantian Zheng, Xin Zheng. Cornell University.
WORKING WITH XSLT AND XPATH
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Copyright 2007 Adobe Systems Incorporated. 1 ColdFusion 8 : Advanced AJAX Development Rakshith N Computer Scientist Jan 02, 2008.
Huffman Encoding Veronica Morales.
JavaScript – Quiz #9 Lecture Code:
Survey on Improving Dynamic Web Performance Guide:- Dr. G. ShanmungaSundaram (M.Tech, Ph.D), Assistant Professor, Dept of IT, SMVEC. Aswini. S M.Tech CSE.
AjaxScope & Doloto: Towards Optimizing Client-side Web 2.0 App Performance Ben Livshits Microsoft Research (joint work with Emre.
PFPC: A Parallel Compressor for Floating-Point Data Martin Burtscher 1 and Paruj Ratanaworabhan 2 1 The University of Texas at Austin 2 Cornell University.
Integer numerical data types. The integer data types The integer data types use the binary number system as encoding method There are a number of different.
Kiew-Hong Chua a.k.a Francis Computer Network Presentation 12/5/00.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
COMPRESSION. Compression in General: Why Compress? So Many Bits, So Little Time (Space) CD audio rate: 2 * 2 * 8 * = 1,411,200 bps CD audio storage:
Compressed Abstract Syntax Trees as Mobile Code Christian H. Stork Vivek Haldar University of California, Irvine.
A Lone Wolf No More: Supporting Network Intrusion Detection with Real-Time Intelligence Shane Singh | COMPSCI 726.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
Scalable Clone Detection and Elimination for Erlang Programs Huiqing Li, Simon Thompson University of Kent Canterbury, UK.
Restricted © Siemens AG All rights reserved A Developer’s Insights Into Performance Optimizations for Mobile Web Apps CT DC AA EM LP2 | June 2015.
Javascript Static Code Analyzer
Martin Kruliš by Martin Kruliš (v1.1)1.
The business logic engine for Microsoft IIS Speaker T.M. Arnett.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5.
Accelerating Multi-Pattern Matching on Compressed HTTP Traffic Dr. Anat Bremler-Barr (IDC) Joint work with Yaron Koral (IDC), Infocom[2009]
A UTOMATICALLY SECURING WEB 2.0 APPLICATIONS THROUGH REPLICATED EXECUTION Ben Livshits Microsoft Research.
Lect5.ppt - 02/23/06 CIS 4100 Systems Performance and Evaluation Lecture 6 by Zornitza Genova Prodanoff.
CS 101 – Sept. 11 Review linear vs. non-linear representations. Text representation Compression techniques Image representation –grayscale –File size issues.
Computer Sciences Department1. 2 Data Compression and techniques.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
Using jqGrid For Rich Web Client App Development Ben Karsin Jesse Elfalan Michael Hodges.
Enhance Your Page Load Speed And Improve Traffic.
Challenges in Pointer Analysis of JavaScript
Programming Web Pages with JavaScript
Introduction to Parsing (adapted from CS 164 at Berkeley)
Viewbiquity HTML5 Tom Shafron Developer’s Blog CEO, Viewbiquity
Doloto: Code Splitting for Web 2.0 Applications
Application with Cross-Platform GUI
Debugging Your Website with Fiddler and Chrome Developer Tools
Web Caching? Web Caching:.
XML in Web Technologies
Doloto: Code Splitting for Web 2.0 Applications
Doloto: Code Splitting for AJAX Applications
JavaScript CS 4640 Programming Languages for Web Applications
Fine-grained and Accurate Source Code Differencing
Presentation transcript:

JSZap: Compressing JavaScript Code Martin Burtscher, UT Austin Ben Livshits & Ben Zorn, Microsoft Research Gaurav Sinha, IIT Kanpur

A Web 2.0 Application Dissected 70,000+ lines of JavaScript code downloaded 2,855 Functions 1+ MB code Talks to 14 backend services (traffic, images, directions, ads, …) Talks to 14 backend services (traffic, images, directions, ads, …) 2

Lots of JavaScript being Transmitted 3 Up to 85% of a Web 2.0 app is JavaScript code!

AJAX: Tension Headaches 4 Execution can’t start without the code Move code to client for responsiveness

JavaScript on the Wire JavaScript crunch gzip -d parser AST JSZap gzip 5

JSZap Approach Represent JavaScript as AST instead of source Serialize the compressed AST Decompress directly into AST on client Use gzip as 2 nd -level (de-)compressor 6

Benefits of AST-based Compression Compression: less to transmit ASTs are blasted directly into the browser Reduced Latency Reduces mobile charges Reduces operator network costs: better for servers Reduced Network Bandwidth Ensures well-formedness of code Can use to check language subsets easily (AdSafe) Caching incremental updates Unblocking HTML parser Correctness, Security, and other Benefits 7

JSZap Compression JavaScript JSZap gzip 8

JSZap Compression JavaScript identifiers gzip literals productions

10 GZIP is a formidable opponent

JSZap vs. GZIP 11

Talk Outline evaluation on real code 12

Background: ASTs a * b + c 1) E  E + T 2) E  T 3) T  T * F 4) T  F 5) F  id + * a b c Expression Grammar Tree

A Simple Javascript Example var y = 2; function foo () { var x = "jscrunch"; var z = 3; z = y + y; } x = "jszap"; Identifier Stream y foo x z z y y x Literal Stream "jscrunch" 2 3 "jszap" 14 Production Stream

Benchmarking JSZap Benchmark nameSource lines Source bytes gmonkey92217,382 getDOMHash1,13625,467 bing13,75877,891 bingmap13,47380,066 livemsg15,30793,982 bingmap29,726113,393 facebook15,886141,469 livemsg27,139156,282 officelive122,016668,051 JavaScript files up to 22K LOC Variety of app types Both hand- generated, and machine-generated gzipped everything 15

Components of JavaScript Source 16 None of the categories can be ignored Identifiers become more prominent with code growth None of the categories can be ignored Identifiers become more prominent with code growth

Compressing the Production Stream Frequency-based production renaming Differential encoding: 26 and 57 => 2 and 3 Chain rule: eliminate predictable productions Tree-based prediction-by-partial-match 17

PPMC Consider compressing – if (P) then X else X Should be very compressible if (P) then...abc... else...abc Tree context used to build a predictor Provides the next likely child node given context C and child position p Arithmetic coding: more likely=shorter IDs See paper for details

Production Compression with PPMC 19

Compressing the Identifier Stream Symbol tables instead of identifier stream: – Compress redundancy: offset into table – Global or local symbol tables – Use variable-length encoding Other techniques: – Sort symbols by frequency – Rename local variables 20

Variable-length Encoding for Identifiers is global? is renamed local 00… 01… fits in 1 byte? 11… 10… 21

Variable-Length Identifier Encoding 22

Symbol Tables: Effectiveness 23

Compressing Literals Symbol tables Grouping literals by type Pre-fixes and post-fixes These techniques result in 5-10% savings compared to gzip 24

Average JSZap Compression: 10% 25

Summary and Conclusions JSZap: AST-based compression for JavaScript Propose a range of techniques for compressing –Productions –Identifiers –Literals Preliminary results are encouraging: 10% savings over gzip Future focus – Latency measurements – Browser integration 26

Well- formedness Security (AdSafe) AST representation Unblocking HTML parser Caching and incremental updates Compression with JSZap 27 ? ? Questions?

References [1]Exploring Last n value Prediction – Martin Burtscher and Benjamin G. Zorn. [2]The Gzip Algorithm - [3]FPC: A High-Speed Compressor for Double-Precision Floating-Point Data – Martin Burtscher and Paruj Ratanaworabhan. 28