Hacking to be Performant?Talk: Performance Engineering
Speaker: Apoorv Saxena
Time to run a poll
How many you consider#perfmatters?
What performance monitoring tools are you
using?(To evaluate your Front End’s Performance)
How many of you have it as part of your
“Continuous Deployment”?
Enough, let’s start Hacking
What do you mean by “Hacking”?
What do you mean by “Performant”?
Evolution of the Web: Browser & Technologies
EvolutionIs necessary, though it proceeds gradually and takes some time, it accounts for everyone to be on the same page.
Though, not everyone can afford to walk at the same speed, they must run, jump obstacles, cut corners and give their best shot.
Loading Webpages under 1 second
First pixel render time less than 500ms
Running Applications at 60fps
Delivering a Jank Free Experience
#perfmatters
What are we Trying to fit?● HTML5 Games● Single Page Applications● Animations● Editors, Document Collaboration Tools● WebRTC (Video, Audio)and many more.
That’s it?
Not at all.
Everything available on Mobile must be available via APIs on Web.
Let me tell you a story
From JS to Screen:
Style/Layout PaintingJS Compositing
keep < 16ms!
1. Add CSS rules in style via JS.2. Recalculate style, maybe relayout.3. Paint the browser’s mental model to a layer4. Composite all layers into a final image
What causes Jank?
Style/Layout PaintingJS
16ms!
Draw Commands CPU GPU
SCREEN
Extensive Upload
Rasterization in Action
Performance Hacks:
Creating a separate layer for elements requesting
frequent updates
Hardware Accelerationrules me
What about using Canvas instead of DOM?
You must consider:
● Accessibility, Flipboard injects mirror of the content into an invisible dom so it’s still in synch for VoiceOver.
● Canvas is not hardware accelerated on every browser (accompanies device constraints).
DOM Rendering might become amazingly fast soon.
(Hint: remember project Ganesh).
Considered using DOMSprites?
SCREEN
Project Ganesh:
Draw Commands GPU
60fps is not required at every instance
Note: Our eyes are much more attuned to variance than framerate.
A steady 30Hz looks better than 60Hz that misses a few frames a second.