• No results found

USING RUST TO BUILD THE NEXT GENERATION WEB BROWSER

N/A
N/A
Protected

Academic year: 2021

Share "USING RUST TO BUILD THE NEXT GENERATION WEB BROWSER"

Copied!
41
0
0

Loading.... (view fulltext now)

Full text

(1)

USING RUST TO BUILD THE NEXT GENERATION WEB BROWSER

Lars Bergstrom Mozilla Research

Mike Blumenkrantz Samsung R&D America

(2)

Why a new web engine?

Support new types of applications and new devices

All modern browser engines (Safari, Firefox, Chrome) originally designed pre-2000

Coarse parallelism

Tightly coupled components

Vast majority of security issues are related to the C++ memory model

(3)

Servo

Written in a memory-safe systems language, Rust

Architected for parallelism

Coarse (per-tab), as in Chrome

Lightweight (intra-page), too

Designed for embedding

(4)

Rust - safe systems programming

C++ syntax and idioms

C++-like performance

Memory safety

Concurrency

Parallelism

http://www.rust-lang.org

(5)

Familiar syntax and performance

Rust playpen

(6)

Memory safety without overhead

Lifetimes and ownership ensure memory safety

No garbage collection

No reference counting

No C++ “smart” pointer classes

(7)

Example of code you can’t write

Rust playpen

(8)

Safe concurrency

Rust playpen

(9)

How a browser works

HTMLCSS JS

DOM Flow

Tree Display

Lists Script

Layout Render

Parsing

More details: http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/

Script &

Interactions

(10)

How a browser works

HTMLCSS JS

DOM Flow

Tree Display

Lists Script

Layout Render

Parsing

This works:

<html>  

 <script>  

 document.write  (“<h”);  

 </script>1>  

 This  is  a  h1  title  

</html>  

More details: http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/

Script &

Interactions

(11)

Timing breakdown

Data from A Case for Parallelizing Web Pages. Mai, Tang, et. al. HOTPAR ‘12

Task Percentage

Runtime libraries 25%

Layout 22%

Windowing 17%

Script 16%

Painting to screen 10%

CSS styling 4%

Other 6%

(12)
(13)

Parallelism within pages

(14)

Servo’s architecture

Constellation

Renderer

Layout Script

Pipeline 1 (iframe 1)

Tab 1

(15)

Servo’s architecture

Constellation

Renderer

Layout Script

Pipeline 1 (iframe 1)

Renderer

Layout Script

Pipeline 2 (iframe 2) Tab 1

(16)

Servo’s architecture

Constellation

Renderer

Layout Script

Pipeline 1 (iframe 1)

Renderer

Layout Script

Pipeline 2 (iframe 2) Tab 1

Renderer

Layout Script

Pipeline 3 (iframe 3)

(17)

Demo: concurrency

(18)

Parallel layout

Matters hugely on mobile platforms

Processors run at lower frequencies, but many cores

Would enable more complicated pages on all platforms

Implemented by work-stealing algorithm

See: Fast and Parallel Webpage Layout. Meyerovich and Bodik. WWW 2010.

(19)

Parallel layout

body

div div div

text bold text text

(20)

Parallel layout

body

div div div

text bold text text

div div div

Queue

(21)

Parallel layout challenges

HTML layout has complex dependencies

Inline element positioning

Floating elements

Vertical text

Pagination

Considering adding speculation

(22)

Parallel layout - wikipedia

Each color is a different processor core

(23)

Parallel layout - reddit

Each color is a different processor core

(24)

Parallel layout speedups (CNN)

(25)

Parallel layout speedups (Reddit)

(26)

Aside: parallelism for power, too

Force low-frequency CPU setting

Above four cores, same end-to-end performance as single core at high-frequency

BUT, 40% of the power usage

Could also parallelize more

Rendering, CSS selector matching, etc.

(27)

Servo vs. Gecko (CNN)

(28)

Servo vs. Gecko (reddit)

(29)

From engine to browser

Servo just renders pages

Similar to the Blink and Gecko engines

Designed to work in many browser shells

Firefox OS, over interprocess communication (IPC)

Android, by implementing a Java wrapper

On the desktop with…

(30)

What is embedding?

Hosting web engine in native application

(31)

Why embed?

Reduced development time

HTML5 popularity

(32)

How not to embed

WebKit

Blink

Both suffer from an unstable API

Application developer choices:

Ship full browser engine with application

Continually update to match breakages

(33)

How to embed?

CEF: Chromium Embedded Framework

Isolates application developers from core API

C API with C++ extensions

(34)

Servo embedding strategy

Stable API/ABI

Extensive API testing is a plus

C-based

Flexible

Already designed

(35)

How to embed with Servo?

Use CEF API+ABI

Removes need for YA embedding API

Less competition, more coding

Allows easy testing between engines

Servo: the pragmatic embedding engine

(36)

Servo embedding methodology

Full symbol/ABI coverage

Every CEF function call resolves to a Servo function

Struct allocation sizes are identical

typedef struct _cef_string_utf8_t { char* str;

size_t length;

void (*dtor)(char* str);

} cef_string_utf8_t;

C

pub struct cef_string_utf8 { pub str: *mut u8,

pub length: size_t,

pub dtor: extern “C” fn(str: *mut u8), }

Rust

(37)

Servo embedding development

Start with base set of symbols

`nm -u` on CEF applications

Track function execution

CEF <-> Blink <-> Application <-> CEF …

Mimic CEF behavior using Servo equivalents

Use preload hacks to test

LD_PRELOAD on Linux

(38)

Servo passes basic browser tests

(39)

Improving CSS feature coverage

https://docs.google.com/spreadsheets/d/1CxLS8w8GwK-2euVErrqpUUb76PiZa6w5h5EnGsL9KFs/edit#gid=555855884

(40)

Servo 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

(41)

Getting involved with Servo

www.github.com/servo/servo/

issues

Filter for “E-Easy”

irc.mozilla.org, #servo channel

Worldwide community

Looking for more partners and contributors

Hiring!

[email protected]

[email protected]

References

Related documents

The difficulty young people experience in finding employment in the formal sector is heavily tied with their lack of experience (van Aardt, 2012: 55) which employers see

Master of Science in Nursing (MSN) quality improvement project identified barriers to Michigan Tobacco Quitline use and implemented a process change to overcome these barriers. The

We examined the effect of solar ultraviolet radiation B (UVB, 280-315 nm) on photosynthesis of natural phytoplankton assemblages in the temperate Changjiang River Estuary (CRE)

Automation of infrastructure provisioning helps individual teams to instantly create their own instances without any help from server administrators, it also helps team to work

To ensure that the phenotype observed in npm1a and npm1b morphants was not a result of p53-mediated morpholino toxicity, the morpholinos directed against npm1a and npm1b were

• These classes will focus on the various financing challenges faced by social entrepreneurs and the financing options available to them (and the legal issues associated with

As mentioned earlier, one of the biggest surprises in the aftermath of Hurricane Sandy was the extensive and effective use of social media and digital tools to share information

Two aspects of eye behaviour are of special interest here: (1) ocular drift during number word presentation and up to the point of saccade launch and (2) parameters of