Top Banner
Understanding Asynchronous Interactions In Full-Stack JavaScript Saba Alimadadi, Ali Mesbah and Karthik Pattabiraman ICSE 2016 [email protected] Sahand: http://github.com/saltlab/sahand
21

Understanding Asynchronous Interactions In Full-Stack ...

Dec 11, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Understanding Asynchronous Interactions In Full-Stack ...

Understanding Asynchronous Interactions

In Full-Stack JavaScript

Saba Alimadadi, Ali Mesbah and Karthik Pattabiraman

ICSE [email protected]

Sahand: http://github.com/saltlab/sahand

Page 2: Understanding Asynchronous Interactions In Full-Stack ...

1

JavaScript:Most popular language

JavaScript:Top languages on GitHub

Page 3: Understanding Asynchronous Interactions In Full-Stack ...

Understanding JavaScript Apps

2

Whole Picture

Page 4: Understanding Asynchronous Interactions In Full-Stack ...

Challenge 1. Server-Side Callbacks

• Asynchronous execution• Callback hell

3

Little pyramidof doom

fs.readdir(source, function(err, files) {files.forEach(function(filename, fileIndex)

gm(source + filename).size(function(err, values) {widths.forEach(function(width, widthIndex) {

this.resize(w, h).write(newName, function(err) {})

})})

})}) // example from callbackhell.com

Page 5: Understanding Asynchronous Interactions In Full-Stack ...

Challenge 2. Network Communications

4

client

server

request 1request 2

processing time 1processing time 2

response 1response 2

Time

Page 6: Understanding Asynchronous Interactions In Full-Stack ...

Challenge 3. Asynchronous Client Side

5

Time

interval

response(timeout)

XHR

server

Page 7: Understanding Asynchronous Interactions In Full-Stack ...

Summary of Challenges

• Server-side callbacks• Network communication• Asynchronous client side

6

Zaidman et al.EMSE’13

Hibschman et al. UIST’14

Alimadadi et al.ICSE’14, ECOOP’15

Related work:

Page 8: Understanding Asynchronous Interactions In Full-Stack ...

Our Approach: Sahand

7

1. Instrument automatically

2. Trace full-stack execution

3. Infer a behavioural model

4. Visualize the model

InaAct Act

Act

ActSch

Application

Page 9: Understanding Asynchronous Interactions In Full-Stack ...

Behavioral Model

8

NodesLifelines of function executions

Act

ActSch Ina Act

Act

(A)Synchronous client/server events

Links Time, Type, Direction

foo()

bar()

baz()

event

Act Ina Act

Page 10: Understanding Asynchronous Interactions In Full-Stack ...

Real Behavioural Models Are Complex

9

Page 11: Understanding Asynchronous Interactions In Full-Stack ...

10

foo()

bar()

baz()

app.js:45

qux()

active

active

active

active

active

act

activescheduled

VisualizationClient-SideAnalysis

Server-SideAnalysis

Connecting client and server

Page 12: Understanding Asynchronous Interactions In Full-Stack ...

baz()

app.js:45

qux()

active

active

act

activescheduled

foo()

bar()

active

active

active

11

VisualizationClient-SideAnalysis

Server-SideAnalysis

Time Temporal primitives Time points

Events and DOM interactionsTimeouts

XHRs

Event loop

Page 13: Understanding Asynchronous Interactions In Full-Stack ...

foo()

bar()

active

active

active

baz()

app.js:45

qux()

active

active

act

activescheduled

12

VisualizationClient-SideAnalysis

Server-SideAnalysis

Time Temporal primitives Time intervals

Function executions

Callbacks

Page 14: Understanding Asynchronous Interactions In Full-Stack ...

baz()

app.js:45

qux()

active

active

act

activescheduled

foo()

bar()

active

active

active

13

VisualizationClient-SideAnalysis

Server-SideAnalysis

Time Structure of time Linear & Branching

Page 15: Understanding Asynchronous Interactions In Full-Stack ...

baz()

app.js:45

qux()

active

active

act

activescheduled

foo()

bar()

active

active

active

14

VisualizationClient-SideAnalysis

Server-SideAnalysis

Time Structure of time Linear & Branching

Page 16: Understanding Asynchronous Interactions In Full-Stack ...

Implementation:Sahand

• Express.js application• Proxy -> dynamic instrumentation• Esprima, Estraverse, Escodegen

https://github.com/saltlab/sahand

15

Page 17: Understanding Asynchronous Interactions In Full-Stack ...

Evaluation

Does using Sahand improve developers’ performance in program comprehension tasks?

16

Page 18: Understanding Asynchronous Interactions In Full-Stack ...

Controlled Experiment

• Sahand’s effect on developers’ performance• 12 Participants• Object: full-stack JavaScript application

17

Page 19: Understanding Asynchronous Interactions In Full-Stack ...

Controlled Experiment

• Design– Control: tool and expertise level – Measure: performance

• Procedure– Pre-questionnaire– Tutorial– Tasks– Post-questionnaire

18

Page 20: Understanding Asynchronous Interactions In Full-Stack ...

Results Highlight

19

T1−Exp

T1−C

trl

T2−Exp

T2−C

trl

T3−Exp

T3−C

trl

Tot−Exp

Tot−Ctrl

0

20

40

60

80

100

Accuracy (%)

Using Sahand3 times more accuracy

In the same time

Accu

racy

Tasks

Control group

Experimental (Sahand) group

Page 21: Understanding Asynchronous Interactions In Full-Stack ...

20Saba Alimadadi Hire Me!

Sahand: http://github.com/saltlab/sahand