rich layout from first principles specification, generation, and parallelization adam jiang, leo...

12
Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot Par 2009, WWW 2010

Upload: beverly-small

Post on 13-Dec-2015

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

Rich Layout from First Principles

Specification, Generation, and Parallelization

Adam Jiang, Leo Meyerovichwith Seth Fowler, John Ng, and RasBodik Hot Par 2009, WWW 2010

Page 2: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

2

Why Layout?parser

DOM CSS rules

selector engine

rendering

21%

23%

12%

29%

9%

JavaScript interpreter

layout engine

parser

selector engine

rendering

JavaScript interpreter

2.4 GHz Macbook Pro, Safari 4.0.3Slashdot, Netflix, MSNBC, Gmail, Facebook, deviantART

WWW2010

our group

43% in IE8

laptop: … 2smobile: … 15s

this talk

Page 3: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

3

The Layout Problem

width=shrinkToFit

width=50% of parent

width=200px…

constraints satisfied

… but strange

unspecified decision to drop constraint

… rest followed

Standard and implementation strategy are unclear

width=shrinkToFit

width=50% of parent

Page 4: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

4

Towards a Mechanized Layout Engine

renderer

CSS DOM

(parallel, incremental, …)layout engine

layout specification(attribute grammar) grammar analyzer

CSS, JavaScript, …(LL1 grammar) grammar analyzer (parallel, incremental, …)

parser

Page 5: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

5

Attribute Grammars

• Knuth ‘67: executable language semantics

• Automation: parallel, incremental, …• Good for IDEs, compiling Pascal-like languages

+

* *

1 2 3 4

<ADD>

<E0> <E1>

this.val = E0.val + E1.val

val, … val, …

val, …

Page 6: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

6

Is Layout Inherently Sequential?

<body>

<p> <p>

<img>hello <b> ok ok ok ok

world

ok

w:100, fs:12

w:50, float:left

w=100, fs=12x=0, y=0

w=100, fs=6x=0, y=0

w=40, fs=6x=0, y=0h=10

h=10w=100, fs=12x=0, y=10

w=50x=0, y=10h=20

w=30, fs=12x=50, y=10h=10

h=10

w=100, fs=12x=0, y=10

h=40

h=40

fs:50%

fs, Δ, w

fs, Δ, w Δ fs,Δ,w

Δ

Δ fs, Δ, w

fs, Δ, w

fs, Δ, w

Page 7: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

7

Dependencies prevent parallelism

<body>

<p> <p>

<img>hello <b> ok ok ok ok

world

ok

w:100, fs:12

w:50, float:left

w=100, fs=12x=0, y=0

w=100, fs=6x=0, y=0

w=40, fs=6x=0, y=0h=10

h=10w=100, fs=12x=0, y=10

w=50x=0, y=10h=20

w=30, fs=12x=50, y=10h=10

h=10

w=100, fs=12x=0, y=10

h=40

h=40

fs:50%

fs, Δ, w

fs, Δ, w Δ fs, Δ,w

Δ

Δ fs, Δ, w

fs, Δ, w

fs, Δ, w

w=40, fs=6x=0, y=0h=10

w=100, fs=12x=0, y=10

Δ

Δ fs, Δ, w

Page 8: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

8

Parallelism from isolating dependencies

<body>

<p> <p>

<img>hello <b> ok ok ok ok

world

ok

w:100, fs:12

w:50, float:left

w=100, fs=12x=0, y=0

w=100, fs=6x=0, y=0

w=40, fs=6x=0, y=0h=10

h=10w=100, fs=12x=0, y=10

w=50x=0, y=10h=20

w=30, fs=12x=50, y=10h=10

h=10

w=100, fs=12x=0, y=10

h=40

h=40

fs:50%

fs, Δ, w

fs, Δ, w Δ fs, Δ,w

Δ

Δ fs, Δ, w

fs, Δ, w

fs, Δ, ww=30,fs=12x=50, y=10h=10

fs, Δ, w

fs, Δ, w

fs, Δ, w

Page 9: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

x w h hx w

innerNode leafNode

fa d

topNode

self

child1 : Node x w h x w h

1. Compute local dependencies

2. Compute transitive dependenciesfor all layouts in this grammar, if dep(a, b, … z), then E(a, b), E(b, c), …

3. Schedule by stitching together (topological sort)

( child1.x := self.x + 23 )

Page 10: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

Automatic Incrementalization of Rendering

Render img1

Render img2

Render img-n

Move display list

Render img1… Render img-n

Move display list 2

Render img z… Render img m(John)

Page 11: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

• Attribute grammar specification promising

• New attribute grammar language• Big benefits

Users: fast and conformant browserDesigners: analysis toolsBrowser developers: separate feature from optimizationStandards: verification (well-defined, backwards compat..)

Takeaway

C++ visitor(ANTLR, …)

declarative grammar

box layoutfloatstables

speculative parallelism?DAGs?

Page 12: Rich Layout from First Principles Specification, Generation, and Parallelization Adam Jiang, Leo Meyerovich with Seth Fowler, John Ng, and RasBodik Hot

Questions?