Closing the Web Platform Gap with Native
Total Page:16
File Type:pdf, Size:1020Kb
Closing the Web Platform Gap with Native Presented by: Moh Haghighat Sr. Principal Engineer, Intel® Corporation March 12, 2014 Agenda • A bit of history, developments • Remaining gaps in web vs. native • Intel®’s work on closing the gaps • Bringing SIMD to JavaScript* • Intel® XDK, Crosswalk* • Towards Perceptual Computing • Summary 2 HTML5 – The New Lingua Franca? 1991 2001 2009 2015 APPS WEB APPS WEB * * * .exe HTML, Flash* iOS , Android , Windows HTML5 Native code Web – “Write once, run on App Stores “Write Once, Run PC spiral any browser” Walled Gardens Everywhere” “New open standards created in the mobile era, such as HTML5, “If you want to do something that is universal, no question, will win on mobile devices.” – Steve Jobs world is going HTML5.” – Steve Ballmer “It looks to me like HTML5 will eventually become a way almost all applications are built, including those on new phones.” – Eric Schmidt 3 JavaScript* Has Grown Up JavaScript* apps grew in size JavaScript* became fast … really fast! Gmail*: Past, Present, and Future, Adam de Boor, Google* www.usenix.org/event/webapps10/tech/slides/deboor.pdf † Modern JavaScript, Luke Hoban, Microsoft* www.microsoft.com Big Web App? Compile it! Alon Zakai, Mozilla* http://kripken.github.io/mloc_emscripten_talk 4 Early JavaScript* JITs, Firefox* TraceMonkey* Firefox* 3.1 with Tracing vs. Firefox 3† Launched early August 2008 Intel® was an early contributor in Firefox JavaScript* JIT compiler † Courtesy of Brendan Eich (http://weblogs.mozillazine.org/roadmap/) 5 Generic JIT Support in Intel® VTune™ Since 2007 JavaScript* JIT’ed code JavaScript* source • Released in 2008 • Hooks in Chrome*, Firefox* LLVM*,… Intel® VTune™ Amplifier JIT API for dynamically generated code 6 Modern processors utilize parallelism to deliver high performance within a constrained power budget 7 Optimizing Web Runtimes for Parallelism Parse + build DOM GPU: parallel JS Other 11% Render 21% 35% Layout Engine * Layout JavaScript 33% CPU: mainly single-threaded Render • HTML5 runtimes of today are not scalable with number of cores • Need parallelism for both responsiveness and energy efficiency Web runtimes need to be parallel end-to-end 8 Parallel Parsing and Compilation bootstrap launch 1 thread 4 threads PESPMA 2009 Epic* Citadel profile on Firefox* Cycle Breakdown by Categories js::compile 4.6 2.2 0.9 JS and GFX execution 6.2 gfx::compile 6.4 Four threads for os::others 43.6 JavaScript* parsing 6.7 js::parse and compilation 12.8 js::others browser::others 16.6 os::mem js::jitted gfx::exec Background JavaScript* JIT compilation now in Chrome*, Firefox*, IE 9 Towards Parallelizing the Browser Layout Engine Layout Engine: a performance bottleneck • Mozilla* Firefox* Page-Load Tests Layout Engine ul em {color:blue} • Zimbra* Collaboration Suite* ~42% execution HotPar 2010 CSS rule matching ~32% of the layout Browser layout engine is a bottleneck but amenable to parallelism 10 River Trail: Parallel JavaScript* • Started at Intel® Labs, now with Mozilla* • Extends JavaScript* with a data-parallel API • Designed for multi-core CPUs and GPUs • Simple, portable, and secure Sequential Array increment example: Accelerated animation of 3D avatars: more characters and more realism A.map(function(a) {return a+1;}); A.mapPar(function(a) {return a+1;}); Parallel Intel and Mozilla* are working on ParallelJS for ECMAScript* ES7 11 SIMD – Single Instruction, Multiple Data Scalar Operation SIMD Operation of Vector Length 4 Ax + Bx = Cx Ax Bx Cx A y + By = Cy Ay By Cy + = Az Bz Cz Az + Bz = Cz Aw Bw Cw A B w + w = Cw Intel® Architecture currently has SIMD operations of vector length 4, 8, 16 SIMD operations deliver great performance & power efficiency 12 SIMD - A Gap Between JavaScript* and Native C++ code for list average SIMD code by ICC * A Google*/Intel/Mozilla* ECMA TC39 joint project “Possible” JavaScript code • Bugzilla*: https://bugzilla.mozilla.org/show_bug.cgi?id=894105 • John McCutchan’s strawman proposal: http://wiki.ecmascript.org/doku.php?id=strawman:simd_number SIMD in JavaScript* further reduces the performance gap 13 Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark* and MobileMark*, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. SIMD.JS – The API Our SIMD prototype delivers ~3x Mandelbrot speedup† † 14 Initial support for float32x4 and int32x4 Combining SIMD and Higher-Level Parallelism WW: Number of WebWorkers SIMD speedup is nicely multiplied by WebWorkers† † Source: Intel® Peter Jensen : https://github.com/PeterJensen/ 15 SIMD.JS Proposal and Polyfill API • SIMD Number (Google* John McCutchan & Intel® Peter Jensen): http://wiki.ecmascript.org/doku.php?id=strawman:simd_number • Polyfill API: https://github.com/johnmccutchan/ecmascript_simd float32x4, int32x4, Float32x4Array, Int32x4Array • Constructors: float32x4(x,y,z,w) float32x4.zero() float32x4.splat(s) • Operations: abs, neg, add, sub, mul, div, clamp, min, max, reciprocal, reciprocalSqrt, scale, sqrt, shuffle, shuffleMix, withX, withY, withZ, withW, lessThan, lessThanOrEqual, equal, notEqual, greaterThanOrEqual, greaterThan, bitsToInt32x4, toInt32x4, … 16 SIMD Speedups on Chromium* 14 SIMD x-times faster than non-SIMD 11.8 12 IVB 32 IVB 64 Bay Trail 10 IVB 32 & 64 : Core™ i7-3667U CPU @ 2.00 GHz, Ubuntu 13 9.5 9.3 Bay Trail : Atom™ CPU Z3770 @ 1.46GHz, Android 4.4 8 6.8 6.5 6.1 6.0 6 5.65.4 5.0 5.0 4.6 4.5 4.2 3.8 3.8 3.9 3.8 Theoretical 3.6 3.4 4 3.2 3.2 3.1 Speedup Limit 2.7 2 0 Transpose4x4 AOBench Mandelbrot MatrixMultiplication VertexTransform Average ShiftRows Matrix4x4Inverse Excellent early results while still focused on functionality 17 ® Intel XDK – Cross-platform Development Kit Free at http://xdk.intel.com Remote debugging & profiling Develop, debug, profile, and build responsive web and hybrid apps 18 Crosswalk* in Brief Today on Android* and Tizen* Latest HTML5 features Based on web technologies: in packaged web apps HTML5, CSS3, JavaScript* Easy addition of Uses Blink* & Chromium* extensible APIs Application Runtime Focuses on security, performance Updated to the latest Follow us at @xwalk_project and standards compliance Chromium every 6th week crosswalk-project.org Easy access to Intel® platform device APIs capabilities 19 Toward Perceptual Computing† 2D/ 3D Object Tracking Close-Range Tracking Speech Recognition Gesture Recognition Facial Analysis Devices sense and perceive user actions in a natural and intuitive way † Source: Intel® Perceptual Computing SDK: intel.com/software/perceptual 20 Enabling 3D Camera on Web Platform • 3D Camera • Beyond color sensing: additional per-pixel distance • Will be widely available on PC and tablets soon • Applications • Real-time hand/finger/object tracking • 3D scanning • Video conferencing: viewpoint and background extraction • Depth on Web Platform † • Capturing: extending W3C Media Capture API with Depth Stream Track • Rendering and post-processing: <video>, <canvas>, WebGL and SIMD.JS • Streaming: transmit as MediaStream via WebRTC RTCPeerConnection † Source: Intel® Ningxin Hu: https://github.com/huningxin/js-handtracking-1/tree/master/demo/fruitNinja 21 Web: The Ubiquitous SW Platform Rich Capabilities & Content Big Data Social Contextual Crowdsourced Sensors “Things” and the Application Model of the Future 22 Summary • Web is the most viable cross-platform solution today • Gap between web and native platforms is closing , Intel is helping • SIMD.JS enables a new class of application domains in JavaScript* • Intel® XDK accelerates HTML5 development • Crosswalk* provides an optimized runtime for packaged web apps and hybrid mobile apps • Web is the application model of the future 23 Join us at the Intel® Booth for Exciting Demos! Legal Disclaimer INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. A "Mission Critical Application" is any application in which failure of the Intel Product could result, directly or indirectly, in personal injury or death. SHOULD YOU PURCHASE OR USE INTEL'S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION, YOU SHALL INDEMNIFY AND HOLD INTEL AND ITS SUBSIDIARIES, SUBCONTRACTORS AND AFFILIATES, AND THE DIRECTORS, OFFICERS, AND EMPLOYEES OF EACH, HARMLESS AGAINST ALL CLAIMS COSTS, DAMAGES, AND EXPENSES AND REASONABLE ATTORNEYS' FEES ARISING OUT OF, DIRECTLY OR INDIRECTLY, ANY CLAIM OF PRODUCT LIABILITY, PERSONAL INJURY, OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL APPLICATION, WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN, MANUFACTURE, OR WARNING OF THE INTEL PRODUCT OR ANY OF ITS PARTS. Intel may make changes to specifications and product descriptions at any time, without notice. Designers