follow your code: node tracing

23
Follow your code: Node/V8 tracing Gireesh Punathil, 26 th Aug 2016

Upload: gireesh-punathil

Post on 14-Apr-2017

66 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Follow your code: Node tracing

Follow your code: Node/V8 tracing

Gireesh Punathil, 26th Aug 2016

Page 2: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Agenda♨Overview of Node/V8 Runtime environment

♨Eclipse as a Node.js development platform

♨Debug Server-side Javascript through Browser

♨Overview of in-built tracing

♨Top tracing options in Node/V8

Page 3: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Philosophy of event-driven programmingTraditional synchronous multi-threaded model

Asynchronous event driven model

Source: http://bit.ly/2baQkwp

Page 4: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing 4

dns

file

net

timer

Hello event driven world!

=> dnscb127.0.0.1

=> fscbName: node …

=> netcb<html> …

=> timercbI am timed out

Anatomy of event loop

Page 5: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

var a = 10var b = ‘g’var c = new Object()

res.on(‘data’, function(d) { data += d});

dynamic typing

async, event driven

born for the cloud

isomorphic

single threaded

Major features of Node.js

Page 6: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Eclipse for Node.js

Node.js a first class citizen in Eclipse

Nodeclipse is the Eclipse plugin for the Node.js

Professional Node.js development made easy, productive and a cool experience

Syntax high-lighting, in-built semantic validation, live debugging, Content assist and much more

Active community support

Page 7: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Prepare Eclipse for Node.js Get the latest Node.js

Get the latest Java

Get the latest Eclipse

In Eclipse install new software

Switch to Node perspective

Page 8: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Debug Server side script in the browser♨Server side code can be very large

♨Quite difficult to follow the control flow and logic

♨console logging very inefficient, and bad practice

♨Native debugging is even more complex

♨At the same time, vetting critical for reliable production

Page 9: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Debug Server side script in the browser♨Install a debugger module

♨Start the application in the debugger

♨Get the debugger port, and access it in the Browser

♨Start following the code!

Page 10: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Page 11: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Tracing the scriptPurposeTrace Javascript functions with input and output

Output

Syntax (Heavy profile)

Page 12: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Log APIsPurposeCollect all the V8 API calls emanating from the application

Output

Syntax

Page 13: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Log Script executionPurposeCollect all the script / function information as and when they are loaded / compiled / recompiled

Output

Syntax

Page 14: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Tracing Garbage CollectionPurposeTrace load in the v8 heap and collection patterns

Output

Syntax

Scavenge collection

Mark-sweep collection

Page 15: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Tracing Call SequencePurposeTrace the code flow path on uncaught exception scenarios

Output

Syntax

Page 16: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Tracing CompilationPurposeTrace optimize compilation decisions and their reasons

Output

Syntax

Page 17: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Tracing Compiled CodePurposeTrace the generated native code for the Javascript source

Output

Syntax

Page 18: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Page 19: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Selectively disable CompilationPurposeIdentify and omit optimize compilation on problematic methods

Output

Syntax

Page 20: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Profile the application for Performance♨Manual profiling inefficient and impractical

♨Adding time measurement cause further burden

♨Native profilers do not provide Javascript insights

♨Large applications often contain performance hideouts

♨Precise performance measures is a hallmark qualifier for software modules

Page 21: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Profile with v8 profiler, view with tick

♨Run the code inside light-weight profiler

♨Rename the generated log file to v8.log

♨Install tick module

♨Post-process the profile log

♨Start analyzing the profile!

Page 22: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

Page 23: Follow your code: Node tracing

Wednesday, May 3, 2023

EclipseSummit 2016, Bangalore Follow your code: Node / V8 tracing

For further learning♨Learn Node.js: https://nodejs.org/en/docs/

♨Learn Javascript: http://www.w3schools.com/js/

♨Learn V8: https://developers.google.com/v8/intro

♨Learn Nodeclipse: http://www.nodeclipse.org

♨Chrome developer tools: https://developer.chrome.com/devtools