SlideShare a Scribd company logo
1 of 43
1 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Adenilson Cavalcanti
BSc MSc
WebKit & Blink committer
W3C CSS WG member
How Servo renders the Web
2Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co.
Summary
Motivation
Rust and Servo
Concepts of Browser engines
Servo high level architecture
Anatomy of a CSS feature
3 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• All modern browser engines were designed 15 years
ago (KHTML, WebKit, Gecko, Blink).
• They fail to exploit full parallelism.
• Both in mobile and desktop we expect more cores
(but not faster clocked CPUs).
Motivation
4 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• Single-threaded:
• Javascript execution
• Layout
• Painting/rasterization
• Security issues derived from C/C++.
• Huge code bases.
Issues of current browser engines
5 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• New browser engine written in Rust.
• Parallel: layout, painting, selector matching.
• Targeting performance and battery saving.
Servo
6 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Demo
Running servo.
7 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Implementation strategy
• Rewrite layout, rendering, HTML/CSS parsing,
networking, core engine glue.
• Reuse JavaScript engine, EME containers,
graphics library, fonts.
• Bootstrap with OpenSSL, image libraries, etc.
8 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• Over 120 CSS properties are supported.
• Rendering real sites near correctly.
• Competitive perf in benchmarks.
• 2x-3x speedups on 4 cores.
Servo status
9 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Rust
10 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
What is Rust?
https://www.youtube.com/watch?v=oKwub2OpsG4
11 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Why Rust?
• It aims to solve some gruesome issues in
C/C++.
• Be more expressive for hard tasks.
• Safety X performance: have both!
The case for Rust
12 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• Compiled language (uses llvm).
• Memory safety.
• Concurrency.
• Parallelism.
Rust features
13 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
C++ x Rust
14 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
C++ example: anything
wrong here?
http://doc.rust-lang.org/nightly/intro.html#ownership
15 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Run on valgrind: warnings
16 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Using gdb to understand
what is happening…
17 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Address: 0x100103af0
Address
18 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Change! Now: 0x100103b10
Address
19 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Ref points to old address!
Compiler warnings won’t catch it:
20 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Rust to the rescue!
21 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Rust stops bugs from
happening.
22 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• Ownership
– Exactly one variable “owns” an allocated value
– Ownership may be transferred (move)
– Ownership may be temporary (borrow)
• Lifetime
– These variables’ scopes provide an upper bound on how long
that value lasts
• Memory safety without overhead
– No GC
– No SmartPointers
– No reference counting
23 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Concepts of browser engines
24 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
How a browser works…
25 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Reasons for lack of literature
First OS
50 60 70 80 90 00 10 20
Books?
First browse
r
OS books
time
Delay between a disruptive tech becoming widespread and t
he textbooks being published
26 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
High level flow
HTML
CSS
JS
Loader /
Parser
DOM
Tree
Script
Handler
Browser
UI
Layout* /
Rendering
user-generated input
*Calculating layout is referred as Reflow (Gecko) or Attachment (WebKit)
27 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo high-level architecture
More details at: http://arxiv.org/abs/1505.07383
HTML
CSS
JS
DOM
Flow
Tree
Display
Lists
Layers
Final
Output
Parsing Styling
Layout
RenderingCompositing
ScriptScript
28 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo threading architecture
Constellation
Renderer
LayoutScript
Pipeline 1 (iframe 1)
Renderer
LayoutScript
Pipeline 2 (iframe 2)
Tab 1
Renderer
LayoutScript
Pipeline 3 (iframe 3)
29 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo rendering pipeline
overview:
• Content (aka. Script):
• Creates and owns the DOM tree
• Layout:
• Takes from content a snapshot of the DOM tree
• Calculates style (attachment), building the flow tree
• Flow tree used to calculate the layout of nodes
• Layout of nodes used to build a display list
• Renderer:
• Receives a display list from layout
• Renders visible portions to one or more tiles in parallel
• Compositor:
• Composites the tiles from the renderer
• Sends the final image to the screen for display
30 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
• In Blink, layout will create a RenderTree with
RenderObjects that have geometric information
and know how to paint themselves.
• In Servo, layout will generate a FlowTree and later
DisplayLists are created from it.
Blink/WebKit Differences
31 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Renderer and Compositor
• Both Renderer and Compositor are:
• Decoupled from Layout (separate threads)
• Design aimed at responsiveness
• Compositor manages its memory.
• Screen is divided into a series of tiles:
• Rendered in parallel
• Required for mobile performance
• Display lists are divided in sublists (i.e. stack context):
• Contents can be retained on the GPU
• Rendered in parallel
32 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Demo
• Dump flowtree, display lists.
• Parallel layout, parallel painting.
33 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Parallel layout challenges
• HTML layout has complex dependencies:
– Inline element positioning
– Floating elements
– Vertical text
– Pagination
• Each page is very different, making static
parallelism prediction difficult.
34 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Parallel layout
div
div
div
Queue
36 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Parallelism reduces page appearance
time
37 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
CSS filter blur
Code analysis.
38 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo detailed roadmap
• https://github.com/servo/servo/wiki/Roadmap
• Q2 2015
– Increase Servo quality - work on more sites
– Demonstrate superior end-to-end
performance
– Mobile / embedded
• 2015
– Full Alpha-quality release
39 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Contributing to Servo &
Rust
Contributions are welcome!
• Servo: github.com/mozilla/servo
• Rust: github.com/mozilla/rust | rust-lang.org
• #servo | #rust | #rust-internals @ irc.mozilla.org
• dev-servo | rust-dev @ lists.mozilla.org
• News: http://blog.servo.org/
40 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Special thanks
• Samsung OSG (OpenSource Group).
• Lars Bergstrom (Mozilla).
• Bruno Abinader (Mapbox).
41Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co.
Questions?
Thank you.
42Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co.
43 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo vs. Gecko (CNN)
44 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley)
Servo vs. Gecko (reddit)

More Related Content

Similar to How Servo Renders the Web

Similar to How Servo Renders the Web (20)

Application Deployment Patterns in the Cloud - NOVA Cloud and Software Engine...
Application Deployment Patterns in the Cloud - NOVA Cloud and Software Engine...Application Deployment Patterns in the Cloud - NOVA Cloud and Software Engine...
Application Deployment Patterns in the Cloud - NOVA Cloud and Software Engine...
 
How Servo Renders the Web
How Servo Renders the WebHow Servo Renders the Web
How Servo Renders the Web
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech People
 
Duel of Two Libraries: Cairo & Skia
Duel of Two Libraries: Cairo & SkiaDuel of Two Libraries: Cairo & Skia
Duel of Two Libraries: Cairo & Skia
 
Servo: The parallel web engine
Servo: The parallel web engineServo: The parallel web engine
Servo: The parallel web engine
 
[E-Dev-Day 2014][14/16] Adding vector graphics support to EFL
[E-Dev-Day 2014][14/16] Adding vector graphics support to EFL[E-Dev-Day 2014][14/16] Adding vector graphics support to EFL
[E-Dev-Day 2014][14/16] Adding vector graphics support to EFL
 
Containerizing couchbase with microservice architecture on mesosphere.pptx
Containerizing couchbase with microservice architecture on mesosphere.pptxContainerizing couchbase with microservice architecture on mesosphere.pptx
Containerizing couchbase with microservice architecture on mesosphere.pptx
 
(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?
 
A295 nodejs-knowledge-accelerator
A295   nodejs-knowledge-acceleratorA295   nodejs-knowledge-accelerator
A295 nodejs-knowledge-accelerator
 
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
Scaling to millions of users with Amazon CloudFront - April 2017 AWS Online T...
 
Netflix Architecture Tutorial at Gluecon
Netflix Architecture Tutorial at GlueconNetflix Architecture Tutorial at Gluecon
Netflix Architecture Tutorial at Gluecon
 
Delivering Mobile Apps That Perform
Delivering Mobile Apps That PerformDelivering Mobile Apps That Perform
Delivering Mobile Apps That Perform
 
Experience Edge at Scale: Implementing the Sitecore Composable Stack
Experience Edge at Scale: Implementing the Sitecore Composable StackExperience Edge at Scale: Implementing the Sitecore Composable Stack
Experience Edge at Scale: Implementing the Sitecore Composable Stack
 
Developing Open Source Leadership
Developing Open Source LeadershipDeveloping Open Source Leadership
Developing Open Source Leadership
 
Measure and Increase Developer Productivity with Help of Serverless at AWS Co...
Measure and Increase Developer Productivity with Help of Serverless at AWS Co...Measure and Increase Developer Productivity with Help of Serverless at AWS Co...
Measure and Increase Developer Productivity with Help of Serverless at AWS Co...
 
CMG2013 Workshop: Netflix Cloud Native, Capacity, Performance and Cost Optimi...
CMG2013 Workshop: Netflix Cloud Native, Capacity, Performance and Cost Optimi...CMG2013 Workshop: Netflix Cloud Native, Capacity, Performance and Cost Optimi...
CMG2013 Workshop: Netflix Cloud Native, Capacity, Performance and Cost Optimi...
 
CSS 3, Style and Beyond
CSS 3, Style and BeyondCSS 3, Style and Beyond
CSS 3, Style and Beyond
 
Microservices and Docker at Scale: The PB&J of Modern Systems
Microservices and Docker at Scale: The PB&J of Modern SystemsMicroservices and Docker at Scale: The PB&J of Modern Systems
Microservices and Docker at Scale: The PB&J of Modern Systems
 
Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019
 
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

How Servo Renders the Web

  • 1. 1 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Adenilson Cavalcanti BSc MSc WebKit & Blink committer W3C CSS WG member How Servo renders the Web
  • 2. 2Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co. Summary Motivation Rust and Servo Concepts of Browser engines Servo high level architecture Anatomy of a CSS feature
  • 3. 3 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • All modern browser engines were designed 15 years ago (KHTML, WebKit, Gecko, Blink). • They fail to exploit full parallelism. • Both in mobile and desktop we expect more cores (but not faster clocked CPUs). Motivation
  • 4. 4 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • Single-threaded: • Javascript execution • Layout • Painting/rasterization • Security issues derived from C/C++. • Huge code bases. Issues of current browser engines
  • 5. 5 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • New browser engine written in Rust. • Parallel: layout, painting, selector matching. • Targeting performance and battery saving. Servo
  • 6. 6 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Demo Running servo.
  • 7. 7 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Implementation strategy • Rewrite layout, rendering, HTML/CSS parsing, networking, core engine glue. • Reuse JavaScript engine, EME containers, graphics library, fonts. • Bootstrap with OpenSSL, image libraries, etc.
  • 8. 8 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • Over 120 CSS properties are supported. • Rendering real sites near correctly. • Competitive perf in benchmarks. • 2x-3x speedups on 4 cores. Servo status
  • 9. 9 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Rust
  • 10. 10 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) What is Rust? https://www.youtube.com/watch?v=oKwub2OpsG4
  • 11. 11 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Why Rust? • It aims to solve some gruesome issues in C/C++. • Be more expressive for hard tasks. • Safety X performance: have both! The case for Rust
  • 12. 12 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • Compiled language (uses llvm). • Memory safety. • Concurrency. • Parallelism. Rust features
  • 13. 13 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) C++ x Rust
  • 14. 14 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) C++ example: anything wrong here? http://doc.rust-lang.org/nightly/intro.html#ownership
  • 15. 15 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Run on valgrind: warnings
  • 16. 16 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Using gdb to understand what is happening…
  • 17. 17 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Address: 0x100103af0 Address
  • 18. 18 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Change! Now: 0x100103b10 Address
  • 19. 19 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Ref points to old address! Compiler warnings won’t catch it:
  • 20. 20 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Rust to the rescue!
  • 21. 21 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Rust stops bugs from happening.
  • 22. 22 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • Ownership – Exactly one variable “owns” an allocated value – Ownership may be transferred (move) – Ownership may be temporary (borrow) • Lifetime – These variables’ scopes provide an upper bound on how long that value lasts • Memory safety without overhead – No GC – No SmartPointers – No reference counting
  • 23. 23 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Concepts of browser engines
  • 24. 24 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) How a browser works…
  • 25. 25 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Reasons for lack of literature First OS 50 60 70 80 90 00 10 20 Books? First browse r OS books time Delay between a disruptive tech becoming widespread and t he textbooks being published
  • 26. 26 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) High level flow HTML CSS JS Loader / Parser DOM Tree Script Handler Browser UI Layout* / Rendering user-generated input *Calculating layout is referred as Reflow (Gecko) or Attachment (WebKit)
  • 27. 27 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo high-level architecture More details at: http://arxiv.org/abs/1505.07383 HTML CSS JS DOM Flow Tree Display Lists Layers Final Output Parsing Styling Layout RenderingCompositing ScriptScript
  • 28. 28 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo threading architecture Constellation Renderer LayoutScript Pipeline 1 (iframe 1) Renderer LayoutScript Pipeline 2 (iframe 2) Tab 1 Renderer LayoutScript Pipeline 3 (iframe 3)
  • 29. 29 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo rendering pipeline overview: • Content (aka. Script): • Creates and owns the DOM tree • Layout: • Takes from content a snapshot of the DOM tree • Calculates style (attachment), building the flow tree • Flow tree used to calculate the layout of nodes • Layout of nodes used to build a display list • Renderer: • Receives a display list from layout • Renders visible portions to one or more tiles in parallel • Compositor: • Composites the tiles from the renderer • Sends the final image to the screen for display
  • 30. 30 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) • In Blink, layout will create a RenderTree with RenderObjects that have geometric information and know how to paint themselves. • In Servo, layout will generate a FlowTree and later DisplayLists are created from it. Blink/WebKit Differences
  • 31. 31 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Renderer and Compositor • Both Renderer and Compositor are: • Decoupled from Layout (separate threads) • Design aimed at responsiveness • Compositor manages its memory. • Screen is divided into a series of tiles: • Rendered in parallel • Required for mobile performance • Display lists are divided in sublists (i.e. stack context): • Contents can be retained on the GPU • Rendered in parallel
  • 32. 32 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Demo • Dump flowtree, display lists. • Parallel layout, parallel painting.
  • 33. 33 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Parallel layout challenges • HTML layout has complex dependencies: – Inline element positioning – Floating elements – Vertical text – Pagination • Each page is very different, making static parallelism prediction difficult.
  • 34. 34 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Parallel layout div div div Queue
  • 35. 36 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Parallelism reduces page appearance time
  • 36. 37 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) CSS filter blur Code analysis.
  • 37. 38 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo detailed roadmap • https://github.com/servo/servo/wiki/Roadmap • Q2 2015 – Increase Servo quality - work on more sites – Demonstrate superior end-to-end performance – Mobile / embedded • 2015 – Full Alpha-quality release
  • 38. 39 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Contributing to Servo & Rust Contributions are welcome! • Servo: github.com/mozilla/servo • Rust: github.com/mozilla/rust | rust-lang.org • #servo | #rust | #rust-internals @ irc.mozilla.org • dev-servo | rust-dev @ lists.mozilla.org • News: http://blog.servo.org/
  • 39. 40 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Special thanks • Samsung OSG (OpenSource Group). • Lars Bergstrom (Mozilla). • Bruno Abinader (Mapbox).
  • 40. 41Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co. Questions?
  • 41. Thank you. 42Open Source Group – Samsung Research America (Silicon Valley) © 2014 Samsung Electronics Co.
  • 42. 43 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo vs. Gecko (CNN)
  • 43. 44 © 2014 Samsung Electronics Co.Open Source Group – Samsung Research America (Silicon Valley) Servo vs. Gecko (reddit)

Editor's Notes

  1. Howdy!
  2. Each tab in servo is represented by a lightweight task thread that implements the Constellation (name is historical). There is a separate thread that handles UI compositing not shown here. Up to this point, we are similar to current Webkit and future Gecko. Within the page in that tab, there is a pipeline that implements the script, layout, and actual rendering. For each iframe, things get interesting. We have a pipeline that consists of three concurrent tasks. The script task handles loading the DOM and JavaScript engine. The layout task turns that into a tree of CSS boxes. The Renderer task turns that into tiles to be displayed on the screen. This architecture permits both parallelism that we didn’t have before and stability. <animate> You can add another pipeline when you add another iframe. And a third iframe can be added, optionally sharing the script task, which can be required in order to support some Web features.
  3. The biggest challenge is that HTML layout is really complicated. Inline elements, like text with various formatting, can require information from its neighbors to know its own position. Floating elements can either shift or even forcibly break (when they have a pinned location) a line in places that do not respect a sequential order of evaluating the DOM nodes. We’re thinking of adding speculative parallelism, but it’s unclear if the extra costs (ability to back out) outweigh the parallelism gains. More evaluation to do here.
  4. Assume we have a page with a body that has three divs, each of which has some text. A top-down traversal (e.g., computing widths) allows the three divs, red, blue, and white to each be rendered in parallel.
  5. These are power numbers for the overall process. Biggest thing to note is that most of the power difference comes from the frequency change, not the number of active cores (not necessarily true on mobile). The big take-away here is that you can save nearly 40% power usage without sacrificing time in this scenario simply by using parallelism and a lower CPU frequency.