thingsmigrate - home | ubc blogsblogs.ubc.ca/karthik/files/2018/07/thingsmigrate_ecoop...migration...
TRANSCRIPT
![Page 1: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/1.jpg)
ThingsMigratePlatform-independent and stateful migration of JavaScript programs
Julien Gascon-SamsonKumseok JungShivanshu GoyalArmin Rezaiean-AselKarthik Pattabiraman
![Page 2: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/2.jpg)
World of computing in 2018
2
![Page 3: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/3.jpg)
World of computing in 2018
Internet of Things
3
![Page 4: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/4.jpg)
World of computing in 2018
Internet of ThingsWeb of Things
4
![Page 5: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/5.jpg)
World of computing in 2018
Internet of ThingsWeb of ThingsIndustry 4.0
5
![Page 6: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/6.jpg)
World of computing in 2018
Internet of ThingsWeb of ThingsIndustry 4.0
Cloud-edge
6
![Page 7: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/7.jpg)
World of computing in 2018
Internet of ThingsWeb of ThingsIndustry 4.0
Cloud-edge
Massive Computer Network
7
![Page 8: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/8.jpg)
World of computing in 2018
8
Cloud
![Page 9: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/9.jpg)
World of computing in 2018
9
Cloud IoT
![Page 10: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/10.jpg)
World of computing in 2018
10
IoTSingle Machine Cloud Cluster
Home Network
Corporate Network
Homogeneous Heterogeneous
![Page 11: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/11.jpg)
World of computing in 2018
11
Cloud
![Page 12: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/12.jpg)
World of computing in 2018
12
Cloud
![Page 13: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/13.jpg)
World of computing in 2018
13
Cloud-Edge
![Page 14: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/14.jpg)
World of computing in 2018
14
$ 5.00
10 KB / frame→ 12,960,000 frames / month (5fps)→ 129.6 GB / month→ $6.48 / month ($50/TB)→ $77.76 / year ~ Raspberry Pi
10 MB / request→ 30 request / month→ 3.6 GB / year→ $2.16 / year
$ 70.00
![Page 15: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/15.jpg)
Motivation
15
● General Purpose “Edge”→ Run stateful applications
![Page 16: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/16.jpg)
Distributed Computing
Motivation
16
● General Purpose “Edge”→ Run stateful applications→ Need to migrate
Scheduling Security
Fault Tolerance
Migration
![Page 17: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/17.jpg)
Distributed Computing
Motivation
17
● General Purpose “Edge”→ Run stateful applications→ Need to migrate
● Heterogeneous system● Resource-constrained
→ Cannot do low-level migration
Scheduling Security
Fault Tolerance
Migration
![Page 18: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/18.jpg)
Distributed Computing in IoT
Motivation
18
● General Purpose “Edge”→ Run stateful applications→ Need to migrate
● Heterogeneous system● Resource-constrained
→ Cannot do low-level migration
Scheduling Security
Fault Tolerance
Platform-Independent Migration
![Page 19: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/19.jpg)
Motivation
19
Low-level Migration
● Program counter● Registers● Memory pages
![Page 20: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/20.jpg)
Motivation
20
Low-level Migration
● Program counter● Registers● Memory pages
High-level Migration
● Stack● Variables● Functions
![Page 21: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/21.jpg)
Motivation
21
Low-level Migration
● Program counter● Registers● Memory pages
Platform-dependent
High-level Migration
● Stack● Variables● Functions
Platform-independent
![Page 22: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/22.jpg)
Motivation
22
One language to rule them all
![Page 23: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/23.jpg)
Motivation
23
One language to rule them all
JavaScript
![Page 24: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/24.jpg)
Motivation
24
One language to rule them all
JavaScript
Douglas Crockford
![Page 25: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/25.jpg)
Motivation
25
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
![Page 26: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/26.jpg)
Motivation
26
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
Actor
actor.on(‘add’, addData)
actor.on(‘update’, updateData)
actor.on(‘search’, searchData)
Behaviour.js
‘update’ ‘search’
![Page 27: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/27.jpg)
Motivation
27
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
Actor
actor.on(‘add’, addData)
actor.on(‘update’, updateData)
actor.on(‘search’, searchData)
Behaviour.jsreturn updateData()
return searchData()
![Page 28: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/28.jpg)
Motivation
28
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
Actor
actor.on(‘add’, addData)
actor.on(‘update’, updateData)
actor.on(‘search’, searchData)
Behaviour.js
![Page 29: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/29.jpg)
Motivation
29
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
JavaScript Application
Module Module Module
C++ Library
Operating System
Drivers
Machine
![Page 30: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/30.jpg)
Motivation
30
One language to rule them all
JavaScript● Event-driven● High-level● Largest user-base
#1
![Page 31: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/31.jpg)
Related Work
31
Lo et al.WWW2013
● Browser to browser
● External Java Server
● One-time migration
![Page 32: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/32.jpg)
Related Work
32
Lo et al.WWW2013
● Browser to browser
● External Java Server
● One-time migration
Kwon et al.WWW2017
● Browser to browser
● Modified VM
![Page 33: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/33.jpg)
Related Work
33
Lo et al.WWW2013
● Browser to browser
● External Java Server
● One-time migration
Kwon et al.WWW2017
● Browser to browser
● Modified VM
ThingsMigrate (this)ECOOP2018
● VM to VM
● Only JavaScript
● Multi-hop migration
⨉ ∞
![Page 34: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/34.jpg)
JavaScript process
Main Challenges
34
source: developer.mozilla.org
![Page 35: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/35.jpg)
JavaScript process
Main Challenges
35
source: developer.mozilla.org
![Page 36: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/36.jpg)
Main Challenges
36
1. Closures2. Events
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
![Page 37: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/37.jpg)
Main Challenges
37
1. Closures2. Events
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
![Page 38: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/38.jpg)
Given a JavaScript program:
1. Instrumentation - Modify code so we can capture state
Approach
38
foo.js foo.instrumented.js
![Page 39: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/39.jpg)
Given a JavaScript program:
1. Instrumentation - Modify code so we can capture state2. Serialization - Serialize state into a snapshot
Approach
39
foo.js foo.instrumented.js foo.snapshot.json
![Page 40: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/40.jpg)
Given a JavaScript program:
1. Instrumentation - Modify code so we can capture state2. Serialization - Serialize state into a snapshot3. Restoration - Generate code from snapshot
Approach
40
foo.js foo.instrumented.js foo.snapshot.json foo.restored.js
![Page 41: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/41.jpg)
Approach
41
Given a JavaScript program:
1. Instrumentation - Modify code so we can capture state2. Serialization - Serialize state into a snapshot3. Restoration - Generate code from snapshot
foo.js foo.instrumented.js foo.snapshot.json foo.restored.js
program = restore(snapshot(program))
![Page 42: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/42.jpg)
Implementation - Instrumentation
42
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
Instrumentation Serialization Restoration
![Page 43: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/43.jpg)
Implementation - Instrumentation
43
var root = new Scope()
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
rootid: ‘root’
Instrumentation Serialization Restoration
![Page 44: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/44.jpg)
Implementation - Instrumentation
44
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 45: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/45.jpg)
Implementation - Instrumentation
45
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
bank(100)
}, 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 46: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/46.jpg)
Implementation - Instrumentation
46
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}, 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 47: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/47.jpg)
Implementation - Instrumentation
47
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
var bank = PiggyBank()
setInterval(
function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}, 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 48: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/48.jpg)
Implementation - Instrumentation
48
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 49: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/49.jpg)
Implementation - Instrumentation
49
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
Instrumentation Serialization Restoration
![Page 50: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/50.jpg)
Implementation - Instrumentation
50
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
scope_0.vars.balance = balance
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
}
return deposit
}
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
Instrumentation Serialization Restoration
![Page 51: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/51.jpg)
Implementation - Instrumentation
51
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
scope_0.vars.balance = balance
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
scope_0.vars.balance = balance
}
return deposit
}
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
Instrumentation Serialization Restoration
![Page 52: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/52.jpg)
Implementation - Instrumentation
52
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
scope_0.vars.balance = balance
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
scope_0.vars.balance = balance
}
scope_0.addFunction(deposit)
return deposit
}
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
Instrumentation Serialization Restoration
![Page 53: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/53.jpg)
Implementation - Instrumentation
53
var root = new Scope()
function PiggyBank(){
var scope_0 = new Scope(root)
var balance = 0
scope_0.vars.balance = balance
var deposit = function(amount){
var scope_0_0 = new Scope(scope_0)
balance += amount
scope_0.vars.balance = balance
}
scope_0.addFunction(deposit)
return deposit
}
root.addFunction(PiggyBank)
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
PiggyBankvalue: /* code */
Instrumentation Serialization Restoration
![Page 54: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/54.jpg)
Implementation - Instrumentation
54
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
/* truncated */
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
PiggyBankvalue: /* code */
Instrumentation Serialization Restoration
![Page 55: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/55.jpg)
Implementation - Instrumentation
55
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
setInterval(
function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}, 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
PiggyBankvalue: /* code */
Instrumentation Serialization Restoration
![Page 56: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/56.jpg)
Implementation - Instrumentation
56
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 57: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/57.jpg)
Implementation - Instrumentation
57
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 58: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/58.jpg)
Implementation - Instrumentation
58
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 59: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/59.jpg)
Implementation - Instrumentation
59
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
Instrumentation Serialization Restoration
![Page 60: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/60.jpg)
Implementation - Instrumentation
60
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
things.setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
putMoneydelay: 1000
putMoneydelay: 1000
…
putMoneydelay: 500
Instrumentation Serialization Restoration
![Page 61: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/61.jpg)
Implementation - Instrumentation
61
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
things.setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)
putMoneydelay: 1000
putMoneydelay: 1000
…
putMoneydelay: 500
Instrumentation Serialization Restoration
![Page 62: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/62.jpg)
Implementation - Instrumentation
62
var root = new Scope()
function PiggyBank(){
/* truncated */
}
root.addFunction(PiggyBank)
var bank = PiggyBank()
root.vars.bank = bank
things.setInterval(
root.addFunction(function putMoney(){
var scope_1 = new Scope(root)
bank(100)
}), 1000)Scope Tree Event Queue
Program
Instrumentation Serialization Restoration
![Page 63: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/63.jpg)
Implementation - Instrumentation
63
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
Scope Tree Event Queue
Program
Instrumentation Serialization Restoration
![Page 64: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/64.jpg)
Implementation - Instrumentation
64
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
Scope Tree Event Queue
Program
Instrumentation Serialization Restoration
![Page 65: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/65.jpg)
Implementation - Instrumentation
65
var pubsub = new Pubsub(‘mqtt://1.2.3.4’)
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
Pubsub
Instrumentation Serialization Restoration
![Page 66: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/66.jpg)
Implementation - Instrumentation
66
var pubsub = new Pubsub(‘mqtt://1.2.3.4’)
pubsub.subscribe(‘snapshot’, function(){
})
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
“snapshot”
Instrumentation Serialization Restoration
![Page 67: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/67.jpg)
Implementation - Instrumentation
67
var pubsub = new Pubsub(‘mqtt://1.2.3.4’)
pubsub.subscribe(‘snapshot’, function(){
var snapshot = root.snapshot()
})
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
snapshot()
Instrumentation Serialization Restoration
![Page 68: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/68.jpg)
Implementation - Instrumentation
68
var pubsub = new Pubsub(‘mqtt://1.2.3.4’)
pubsub.subscribe(‘snapshot’, function(){
var snapshot = root.snapshot()
pubsub.publish(‘snapshots’, snapshot)
})
var root = new Scope()
function PiggyBank(){
/* truncated */
}
/* truncated */
publish
Instrumentation Serialization Restoration
![Page 69: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/69.jpg)
Implementation - Serialization
69
putMoneydelay: 1000
putMoneydelay: 500
putMoneydelay: 1000
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Scope Tree Event Queue
…
Instrumentation Serialization Restoration
![Page 70: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/70.jpg)
Implementation - Serialization
70
putMoneydelay: 1000
putMoneydelay: 1000
putMoneydelay: 1000
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 0
Scope Tree Event Queue
…
1
2
3
0var bank = PiggyBank()
Instrumentation Serialization Restoration
![Page 71: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/71.jpg)
Implementation - Serialization
71
putMoneydelay: 1000
putMoneydelay: 1000
putMoneydelay: 1000
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 100
Scope Tree Event Queue
…scope_1
id: ‘putMoney/0’scope_0_0
id: ‘PiggyBank/0/deposit/0’
1
2
3
0var bank = PiggyBank()
putMoney()
Instrumentation Serialization Restoration
![Page 72: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/72.jpg)
Implementation - Serialization
72
putMoneydelay: 1000
putMoneydelay: 1000
putMoneydelay: 1000
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
Scope Tree Event Queue
…scope_1
id: ‘putMoney/0’scope_0_0
id: ‘PiggyBank/0/deposit/0’
scope_1id: ‘putMoney/1’
scope_0_0id: ‘PiggyBank/0/deposit/1’
1
2
3
0var bank = PiggyBank()
putMoney()
putMoney()
Instrumentation Serialization Restoration
![Page 73: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/73.jpg)
Implementation - Serialization
73
putMoneydelay: 1000
putMoneydelay: 1000
putMoneydelay: 500
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
Scope Tree Event Queue
…scope_1
id: ‘putMoney/0’scope_0_0
id: ‘PiggyBank/0/deposit/0’
scope_1id: ‘putMoney/1’
scope_0_0id: ‘PiggyBank/0/deposit/1’
1
2
3
0var bank = PiggyBank()
putMoney()
putMoney()
root.snapshot()
Instrumentation Serialization Restoration
![Page 74: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/74.jpg)
Implementation - Serialization
74
putMoneydelay: 1000
putMoneydelay: 1000
putMoneydelay: 500
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
Scope Tree Event Queue
…scope_1
id: ‘putMoney/0’scope_0_0
id: ‘PiggyBank/0/deposit/0’
scope_1id: ‘putMoney/1’
scope_0_0id: ‘PiggyBank/0/deposit/1’
1
2
3
0var bank = PiggyBank()
putMoney()
putMoney()
root.snapshot()
Instrumentation Serialization Restoration
![Page 75: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/75.jpg)
Implementation - Serialization
75
putMoneydelay: 500
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
Scope Tree Event Queue
…
1
2
3
0var bank = PiggyBank()
putMoney()
putMoney()
root.snapshot()
Instrumentation Serialization Restoration
![Page 76: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/76.jpg)
Implementation - Serialization
76
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
Instrumentation Serialization Restoration
![Page 77: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/77.jpg)
Implementation - Serialization
77
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
Instrumentation Serialization Restoration
![Page 78: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/78.jpg)
Implementation - Serialization
78
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
Instrumentation Serialization Restoration
![Page 79: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/79.jpg)
Implementation - Serialization
79
function PiggyBank(){
var balance = 0
var deposit = function(amount){
balance += amount
}
return deposit
}
var bank = PiggyBank()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
‘root’: { ‘vars’: { ‘bank’: { ‘type’: ‘function-reference’, ‘value’: ‘PiggyBank/0.deposit’ } }}
Instrumentation Serialization Restoration
![Page 80: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/80.jpg)
Implementation - Serialization
‘root’: { ‘vars’: { ‘bank’: { /* truncated */ } }, ‘children’: { ‘PiggyBank/0’: { ‘vars’: { /* truncated */ } } } ‘timers’: { ‘0’: { ‘type’: ‘Interval’, ‘callback’: ‘putMoney’, ‘delay’: 1000, ‘remaining’: 500 }}
80
Instrumentation Serialization Restoration
![Page 81: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/81.jpg)
Implementation - Restoration
81
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 82: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/82.jpg)
Implementation - Restoration
82
var root = new Scope()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 83: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/83.jpg)
Implementation - Restoration
83
var root = new Scope()
(function PiggyBank_0(){
var scope_0 = new Scope(root)
})()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 84: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/84.jpg)
Implementation - Restoration
84
var root = new Scope()
(function PiggyBank_0(){
var scope_0 = new Scope(root)
var balance = 200
scope_0.vars.balance = balance
})()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 85: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/85.jpg)
Implementation - Restoration
85
var root = new Scope()
(function PiggyBank_0(){
var scope_0 = new Scope(root)
var balance = 200
scope_0.vars.balance = balance
var deposit = function(amount){
/* Original code */
}
scope_0.addFunction(deposit)
})()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 86: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/86.jpg)
Implementation - Restoration
86
var root = new Scope()
(function PiggyBank_0(){
/* truncated */
})()
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 87: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/87.jpg)
Implementation - Restoration
87
var root = new Scope()
(function PiggyBank_0(){
/* truncated */
})()
function PiggyBank(){
/* Original code */
}
root.addFunction(PiggyBank)
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 88: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/88.jpg)
Implementation - Restoration
88
var root = new Scope()
(function PiggyBank_0(){
/* truncated */
})()
function PiggyBank(){
/* Original code */
}
root.addFunction(PiggyBank)
root.addFunction(function putMoney(){
/* Original code */
})
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 89: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/89.jpg)
Implementation - Restoration
89
var root = new Scope()
(function PiggyBank_0(){
/* truncated */
})()
function PiggyBank(){
/* Original code */
}
root.addFunction(PiggyBank)
root.addFunction(function putMoney(){
/* Original code */
})
var bank =
root.getFunction(‘PiggyBank/0.deposit’)
root.vars.bank = bank
rootid: ‘root’
scope_0id: ‘PiggyBank/0’
balancevalue: 200
depositvalue: /* code */
bankvalue: deposit
PiggyBankvalue: /* code */
putMoneyvalue: /* code */
Instrumentation Serialization Restoration
![Page 90: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/90.jpg)
Experiment
90
Pubsub Service
Web Dashboard(Manager)
Worker
Worker
Worker
MQTT
HTTP
Legend
![Page 91: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/91.jpg)
Experiment
91
github.com/karthikp-ubc/ThingsJS
Project available on Github
![Page 92: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/92.jpg)
Results
92
Benchmarks
● Chrome Octane Suite○ NavierStokes - CPU intensive○ Splay - Memory intensive
● Factorial● Regulator
![Page 93: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/93.jpg)
Results
93
Execution Time
cloud pi3 pi0
![Page 94: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/94.jpg)
Results
94
Execution Time
cloud pi3 pi0
+ 5 ~ 40% Execution Time
![Page 95: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/95.jpg)
Results
95
Memory Usage
cloud pi3 pi0
![Page 96: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/96.jpg)
Results
96
Memory Usage
~ 3x Memory Usage
cloud pi3 pi0
![Page 97: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/97.jpg)
Results
97
Multi-hop Behaviour
![Page 98: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/98.jpg)
Results
98
Multi-hop Behaviour
Constant Snapshot Size
![Page 99: ThingsMigrate - Home | UBC Blogsblogs.ubc.ca/karthik/files/2018/07/ThingsMigrate_ecoop...Migration Distributed Computing in IoT Motivation 18 General Purpose “Edge” → Run stateful](https://reader033.vdocuments.us/reader033/viewer/2022053023/6055766febb5120bf7168eb7/html5/thumbnails/99.jpg)
We provide a high-level migration framework for JavaScript programs
● Stateful applications● Platform-independent● No VM modification
99
thingsjs.juliengs.com
1. Optimizationa. Memory usageb. CPU usage
2. Fault-tolerancea. Infinite blocking loops/recursionb. Checkpointingc. Real-time state streaming
3. Decentralized scheduling
tl;drFuture Work