PPT模板下载:www.1ppt.com/moban/

Performance on JS
Briefing

What's this topic about
杨琦 UCWEB 浏览器研发部
Topics
Scope:
– Single-page application
– Ajax and Web 2.0
– Download and execute more code as you interact

Topics:
– Variable Scope Management
– Data accessing
– Loops & Functions
– ASMJS
Variable Scope Management

Scope Chain Matters?
Scope Chain ?
How to find out a variable ?
– Variable inside javascript: Data Reference.
– How to locate a variable in functions: From Local to Global
– What does the VM do before execution a function?
嗗 Create a stackframe before getting into functions
嗗 Reference all the outer function variables by pointers to array in stackframe
嗗 Referencing local variables in stackframe
嗗 Push stackframe into vm's execution context
嗗 All the stackframes => Scope Chain

– What does the VM do during execution ?
Scope Chain ?
Matters ?
It really matters?
– Testing cases:
嗗 scope chain lookups
嗗 Scope Chain
嗗 Simple Test

– ResuIt: It does NOT matter !

Special cases
– try/catch
– try/catch with fail
Scope Chain ?
Why ?
– Just in time compiler!
嗗 All the variables is looked up inside the scope chain as less times as possible.
嗗 Once referenced, cached it!
嗗 Check the type & avaibilities on the fly with minus cost (usually assembly code)

– The state of art javascript vm supporting jit!

What matters ?
– Calling slower routings (exception blow up)
– Variable type changed during executions (delete a.b)
Data accessing

Data accessing Matters?
Ways of data accessing
Data variables for accessing
– Literal value
– Variable
– Object property
– Array item
The old report
Data variables for accessing
– Literal value
– Variable
– Object property
– Array item
The latest report
Data variables for accessing
– Variable vs Object property
嗗 Nearly the same. Thanks to hidden class and jit.
嗗 A hidden class is some hint that provide the jit how to access the property data inside
a object.

– Array item vs Object property
嗗 Object is faster than array in dealing with sparse data.
Loop & Functions

What Matters?
Loops
for (a in b) / forEach
– Loops tests
– for (A in B )?
嗗 Same:
– Pickout A from B each loop
– Create reference on the fly

嗗 Diff:
– foreach use iterator & generator
– for-in track whether this property is enumable.

– Using normal while/for loop will be better.

For / While
– For vs While
– It is nearly the same
Functions
Arguments/ Prameters
– args vs params
– Please using parameters.

Function Costs
– Function cost
嗗 Creating stackframes.
嗗 Maintaining local variables.
嗗 GC.

– Try to inline something
ASMJS

Not ready!
ASMJS
ASMJS ?
– an extraordinarily optimizable, low-level subset of JavaScript

Performance Boost?
– fib normal vs asm
嗗 Using asmjs slower! (Due to compilation overhead)
嗗 DFG etc is enough to find out the data types.

– asm vs no-asm

Conclusion
– Better NOT use it now!
Rock & Roll
Write simple code !
Do not use asmjs now!
Use more hint to ignite the v8/squirrelfish !
Q&A
THANKS FOR YOUR LISTENING

More Related Content

PPT
Perf onjs final
PDF
War of Native Speed on Web (SITCON2016)
PDF
Load test REST APIs using gatling
ODP
Gatling
PPTX
Promise of a better future by Rahul Goma Phulore and Pooja Akshantal, Thought...
ODP
Drilling the Async Library
PDF
Gatling @ Scala.Io 2013
ODP
Boost your App with Gatling
Perf onjs final
War of Native Speed on Web (SITCON2016)
Load test REST APIs using gatling
Gatling
Promise of a better future by Rahul Goma Phulore and Pooja Akshantal, Thought...
Drilling the Async Library
Gatling @ Scala.Io 2013
Boost your App with Gatling

What's hot (20)

PDF
The Future starts with a Promise
ODP
Lyonrb 12feb2014-sidekiq
PDF
Introduction to Functional Reactive Programming
PPTX
Top 10 RxJs Operators in Angular
PDF
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
PDF
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
PPTX
Intro to RxJS
PPTX
What’s expected in Spring 5
PDF
Variables in Pharo5
PDF
rx-java-presentation
PPTX
Reactive Extensions for JavaScript
PDF
Powering machine learning workflows with Apache Airflow and Python
PDF
Reactive java - Reactive Programming + RxJava
PDF
Introducing Apache Airflow and how we are using it
PDF
Apollo server II
PDF
Reactive programming with Rxjava
PDF
Apache Airflow
PPTX
Apache Airflow Introduction
PDF
OASGraph LoopBack 4 Integration
PDF
New in Spring Framework 5.0: Functional Web Framework
The Future starts with a Promise
Lyonrb 12feb2014-sidekiq
Introduction to Functional Reactive Programming
Top 10 RxJs Operators in Angular
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Intro to RxJS
What’s expected in Spring 5
Variables in Pharo5
rx-java-presentation
Reactive Extensions for JavaScript
Powering machine learning workflows with Apache Airflow and Python
Reactive java - Reactive Programming + RxJava
Introducing Apache Airflow and how we are using it
Apollo server II
Reactive programming with Rxjava
Apache Airflow
Apache Airflow Introduction
OASGraph LoopBack 4 Integration
New in Spring Framework 5.0: Functional Web Framework
Ad

Viewers also liked (17)

PPTX
Sr. Jorge Mujíca, Director de Tecnologías (CTO) de IBM Chile, "IBM Watson: e...
PDF
Dell PowerEdge Porfolio 2013
DOCX
Mapa planificación.
DOCX
Bomba de veneno(3)
PPTX
Reaching 100s of milllions at WWF
PPTX
Incoterm
PPTX
гуп презентация нефт. промышленность
PPTX
Hader bustos vacation
PDF
El rubi lectura y escritura
PPT
Technology & Social Interaction
DOCX
Mapa de los recursos audiovisuales
PPT
7. Mensaje de Emanuel Swedenborg
PPTX
Egipat
PPTX
Birthday celebrators for the month of October- Tondo High School Teachers Tea...
PDF
Actividades de tercero y cuarto primaria
PDF
Chemical & hygiene systems pdf document aqua middle east fzc
Sr. Jorge Mujíca, Director de Tecnologías (CTO) de IBM Chile, "IBM Watson: e...
Dell PowerEdge Porfolio 2013
Mapa planificación.
Bomba de veneno(3)
Reaching 100s of milllions at WWF
Incoterm
гуп презентация нефт. промышленность
Hader bustos vacation
El rubi lectura y escritura
Technology & Social Interaction
Mapa de los recursos audiovisuales
7. Mensaje de Emanuel Swedenborg
Egipat
Birthday celebrators for the month of October- Tondo High School Teachers Tea...
Actividades de tercero y cuarto primaria
Chemical & hygiene systems pdf document aqua middle east fzc
Ad

Similar to 面向引擎——编写高效率JS (20)

PDF
JavaScript and jQuery - Web Technologies (1019888BNR)
PPT
JavaScript Misunderstood
PPTX
Cordova training : Day 4 - Advanced Javascript
PPTX
Object oriented java script
PDF
Fii Practic Frontend - BeeNear - laborator3
PPT
Introduction to Javascript
PPTX
JavaScript OOPS Implimentation
PDF
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
PPTX
Javascript Basics by Bonny
PDF
WEB MODULE 3.pdf
PPTX
Javascripts. pptt
PDF
A Deep Dive into Javascript
PPTX
Lecture 4- Javascript Function presentation
PPTX
JavaScript, VBScript, AJAX, CGI
PPTX
Object Oriented Programming In JavaScript
PPT
JavaScript - An Introduction
PPTX
javascript client side scripting la.pptx
PPTX
IWT presentation121232112122222225556+556.pptx
PPTX
javaScript and jQuery
PDF
Basics of JavaScript
JavaScript and jQuery - Web Technologies (1019888BNR)
JavaScript Misunderstood
Cordova training : Day 4 - Advanced Javascript
Object oriented java script
Fii Practic Frontend - BeeNear - laborator3
Introduction to Javascript
JavaScript OOPS Implimentation
(COSCUP 2015) A Beginner's Journey to Mozilla SpiderMonkey JS Engine
Javascript Basics by Bonny
WEB MODULE 3.pdf
Javascripts. pptt
A Deep Dive into Javascript
Lecture 4- Javascript Function presentation
JavaScript, VBScript, AJAX, CGI
Object Oriented Programming In JavaScript
JavaScript - An Introduction
javascript client side scripting la.pptx
IWT presentation121232112122222225556+556.pptx
javaScript and jQuery
Basics of JavaScript

Recently uploaded (20)

PPTX
Microsoft User Copilot Training Slide Deck
PDF
Advancing precision in air quality forecasting through machine learning integ...
PPTX
Configure Apache Mutual Authentication
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
DOCX
search engine optimization ppt fir known well about this
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Microsoft User Copilot Training Slide Deck
Advancing precision in air quality forecasting through machine learning integ...
Configure Apache Mutual Authentication
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
Improvisation in detection of pomegranate leaf disease using transfer learni...
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Early detection and classification of bone marrow changes in lumbar vertebrae...
sbt 2.0: go big (Scala Days 2025 edition)
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Lung cancer patients survival prediction using outlier detection and optimize...
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Taming the Chaos: How to Turn Unstructured Data into Decisions
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
search engine optimization ppt fir known well about this
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Data Virtualization in Action: Scaling APIs and Apps with FME
Flame analysis and combustion estimation using large language and vision assi...
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf

面向引擎——编写高效率JS

  • 2. Briefing What's this topic about 杨琦 UCWEB 浏览器研发部
  • 3. Topics Scope: – Single-page application – Ajax and Web 2.0 – Download and execute more code as you interact Topics: – Variable Scope Management – Data accessing – Loops & Functions – ASMJS
  • 5. Scope Chain ? How to find out a variable ? – Variable inside javascript: Data Reference. – How to locate a variable in functions: From Local to Global – What does the VM do before execution a function? 嗗 Create a stackframe before getting into functions 嗗 Reference all the outer function variables by pointers to array in stackframe 嗗 Referencing local variables in stackframe 嗗 Push stackframe into vm's execution context 嗗 All the stackframes => Scope Chain – What does the VM do during execution ?
  • 7. Matters ? It really matters? – Testing cases: 嗗 scope chain lookups 嗗 Scope Chain 嗗 Simple Test – ResuIt: It does NOT matter ! Special cases – try/catch – try/catch with fail
  • 8. Scope Chain ? Why ? – Just in time compiler! 嗗 All the variables is looked up inside the scope chain as less times as possible. 嗗 Once referenced, cached it! 嗗 Check the type & avaibilities on the fly with minus cost (usually assembly code) – The state of art javascript vm supporting jit! What matters ? – Calling slower routings (exception blow up) – Variable type changed during executions (delete a.b)
  • 10. Ways of data accessing Data variables for accessing – Literal value – Variable – Object property – Array item
  • 11. The old report Data variables for accessing – Literal value – Variable – Object property – Array item
  • 12. The latest report Data variables for accessing – Variable vs Object property 嗗 Nearly the same. Thanks to hidden class and jit. 嗗 A hidden class is some hint that provide the jit how to access the property data inside a object. – Array item vs Object property 嗗 Object is faster than array in dealing with sparse data.
  • 14. Loops for (a in b) / forEach – Loops tests – for (A in B )? 嗗 Same: – Pickout A from B each loop – Create reference on the fly 嗗 Diff: – foreach use iterator & generator – for-in track whether this property is enumable. – Using normal while/for loop will be better. For / While – For vs While – It is nearly the same
  • 15. Functions Arguments/ Prameters – args vs params – Please using parameters. Function Costs – Function cost 嗗 Creating stackframes. 嗗 Maintaining local variables. 嗗 GC. – Try to inline something
  • 17. ASMJS ASMJS ? – an extraordinarily optimizable, low-level subset of JavaScript Performance Boost? – fib normal vs asm 嗗 Using asmjs slower! (Due to compilation overhead) 嗗 DFG etc is enough to find out the data types. – asm vs no-asm Conclusion – Better NOT use it now!
  • 18. Rock & Roll Write simple code ! Do not use asmjs now! Use more hint to ignite the v8/squirrelfish !
  • 19. Q&A
  • 20. THANKS FOR YOUR LISTENING