55
The Perf Doctor josh holmes joshholmes.com @joshholmes [email protected]

BrazilJS Perf Doctor Talk

Embed Size (px)

DESCRIPTION

Building a high performance front end is a balancing act. You need to understand all the different moving parts and subsystems in the browser and how they interact with each other. Small changes can significantly impact page and app load time, memory consumption, and processor use which has a huge impact on your user’s experience! In this session, we will dive into the subsystems of the browser and learn to optimize performance on sites and in web apps. We will also deep dive into the new performance analyzing tools available expose good and bad run-time patterns for your sites and web apps, and provide users with a fast and fluid experience.

Citation preview

Page 1: BrazilJS Perf Doctor Talk

The Perf Doctorjosh [email protected]@microsoft.com

Page 2: BrazilJS Perf Doctor Talk

Josh Holmes@joshholmes

[email protected]://www.joshholmes.com

http://slideshare.net/joshholmes

Page 3: BrazilJS Perf Doctor Talk

#zen

Page 4: BrazilJS Perf Doctor Talk

#yum

Page 5: BrazilJS Perf Doctor Talk

#yum

Page 6: BrazilJS Perf Doctor Talk

#yum

Page 7: BrazilJS Perf Doctor Talk

#hero

Page 8: BrazilJS Perf Doctor Talk

#hero

Page 9: BrazilJS Perf Doctor Talk

#hero

Page 10: BrazilJS Perf Doctor Talk

#holycowdidthatjusthappen

Page 11: BrazilJS Perf Doctor Talk

Agenda• Defining Performance• Web Runtime Architecture• Performance Measurement Tools• Walkthroughs / Demos

Page 12: BrazilJS Perf Doctor Talk

Performance ExerciseHow much do you know about

performance?

Page 13: BrazilJS Perf Doctor Talk
Page 14: BrazilJS Perf Doctor Talk
Page 15: BrazilJS Perf Doctor Talk

• Anonymized data from each of the travel sites

Travel Site ContentTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS OtherScriptaculous

Page 16: BrazilJS Perf Doctor Talk

• Total size differs by almost a factor of four

Travel Site Content – Total SizeTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS OtherScriptaculous

Page 17: BrazilJS Perf Doctor Talk

• Constructed DOM elements differs by over a factor of four

Travel Site Content – Number Elements

Total Size (k)

Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 18: BrazilJS Perf Doctor Talk

• Total CSS rules vary by nearly a factor of five

Travel Site Content – CSS RulesTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 19: BrazilJS Perf Doctor Talk

• The image files downloaded on the sites vary by a factor of eleven

Travel Site Content – Image FilesTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 20: BrazilJS Perf Doctor Talk

• Formatted JavaScript lines vary by almost a factor of eight

Travel Site Content – Script LinesTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 21: BrazilJS Perf Doctor Talk

• Every site uses jQuery at the minimum but sites #1 and #2 are using additional libraries and frameworks as well.

Travel Site Content – Script LibrariesTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS OtherScriptaculous

Page 22: BrazilJS Perf Doctor Talk

Which site is fastest?

Page 23: BrazilJS Perf Doctor Talk

• Site #5 is the fastest despite having three times more script lines than sites #3 and #4

Site #5 Is FastestTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 24: BrazilJS Perf Doctor Talk

Which site is slowest?

Page 25: BrazilJS Perf Doctor Talk

• Site #2 is the slowest despite having relatively low number of elements and staying in the middle of the pack on the other metrics.

Site #2 is SlowestTotal Size

(k)Number Elements

CSS Rules Image Files Script Lines

(F)Script

Libraries

Site #1 3,697 1,504 1,392 41 77,768

Site #2 2,278 1,100 5,325 29 39,183

Site #3 1,061 2,673 1,105 66 12,643

Site #4 1,812 4,252 1,672 12 10,284

Site #5 1,372 900 3,902 6 38,269

YUIjQuery Prototype ExtJS Scriptaculous Other

Page 26: BrazilJS Perf Doctor Talk

Web Performance Factors

What Makes Sites Faster?

Page 27: BrazilJS Perf Doctor Talk

Core 1 Core 2

Core 3 Core 4GPU

Page 28: BrazilJS Perf Doctor Talk

Web Runtime Architecture

Page 29: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 30: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 31: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 32: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 33: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 34: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 35: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 36: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 37: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 38: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 39: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 40: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 41: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 42: BrazilJS Perf Doctor Talk

Networking Parsers

1

2 7

43 8 9

5 6

DOMTree

Formatting Layout Painting

1

2 7

43 8 9

5 6

Display Tree

Compositing

DOM API&

Capabilities

JavaScript

Touch

Hit Testing

InputCSS Cascade

Page 43: BrazilJS Perf Doctor Talk

Always start with a good profiler

Windows Performance Toolkithttp://aka.ms/WinPerfKit

F12 UI Responsiveness Tool

Page 44: BrazilJS Perf Doctor Talk

Event Tracing for Windows (ETW) allows us to see into the web platform architecture

Event Tracing for Windows (ETW)controller

Provider A

Provider B

Provider C

Trace Files

Session

Buffer

Windows

consumer

ETW

Enable / Disable

Session Control

Page 45: BrazilJS Perf Doctor Talk

F12 Developer Tools

Page 46: BrazilJS Perf Doctor Talk

F12 Developer Tools

Page 47: BrazilJS Perf Doctor Talk

F12 Developer Tools

Page 48: BrazilJS Perf Doctor Talk

F12 Developer Tools

Page 49: BrazilJS Perf Doctor Talk

Windows Performance ToolkitWindows Performance Toolkit contains an ETW controller (Windows Performance Recorder) and an ETW consumer (Windows Performance Analyzer) that we can use to analyze performance.

• Windows Performance Toolkit:http://aka.ms/performance

• Measuring Browser Performance:

• http://aka.ms/MeasureBrowser Perf

Page 50: BrazilJS Perf Doctor Talk

Where’s IE11 now?• Dev preview• Win 8.1• Windows 7 - No perf tools just yet but coming with RTM

• New features• F12 Dev Tools (like you just saw)• UA string change

Site compatibility just works• WebGL is awesome• Evergreen updates• More standards• More GPU• More awesomesauce

Page 51: BrazilJS Perf Doctor Talk
Page 52: BrazilJS Perf Doctor Talk
Page 53: BrazilJS Perf Doctor Talk

The Internet Explorer userAgent community recognizes, supports, and connects passionate web developers to raise awareness of web standards and the importance of delighting users with rich interoperable web experiences.

http://userAgents.ie

Page 54: BrazilJS Perf Doctor Talk

#thanks

Page 55: BrazilJS Perf Doctor Talk

http://www.flickr.com/photos/-bast-/349497988/

josh [email protected]@microsoft.com