git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit d0a5ea25b9d19aad6f2be59441be57da023c9c70

make shutdown sync

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 4/14/2018, 7:02:15 PM
Parent: 1cb8325aadecdc8aed5d21bf203f529a4879d5b8

Files changed

actor.jschanged
benchmark/index.jschanged
egressDriver.jschanged
index.jschanged
package-lock.jsonchanged
package.jsonchanged
scheduler.jschanged
tests/index.jschanged
actor.jsView
@@ -27,12 +27,12 @@
2727
2828 /**
2929 * Runs the shutdown routine for the actor
3030 */
31- async shutdown () {
32- await this.tree.set(this.id.id, [this.type, this.nonce])
33- const state = await this.tree.get(this.id.id)
34- return this.tree.graph.set(state.root, '2', this.storage)
31+ shutdown () {
32+ // saves the nonce and storage to the state
33+ this.state.value[1] = this.nonce
34+ this.state.node[2] = {'/': this.storage}
3535 }
3636
3737 /**
3838 * Runs the startup routine for the actor
benchmark/index.jsView
@@ -25,17 +25,18 @@
2525 }
2626 }
2727
2828 async function main (numOfActors, depth) {
29- // const messageOrder = {}
29+ const tree = new RadixTree({
30+ db
31+ })
32+
3033 let numOfMsg = 0
34+
3135 class BenchmarkContainer extends BaseContainer {
3236 main () {
3337 const refs = [...arguments]
3438 const ref = refs.pop()
35- // const last = messageOrder[this.actor.id.toString('hex')]
36- // const message = this.actor.currentMessage
37- // messageOrder[this.actor.id.toString('hex')] = message._fromTicks
3839 numOfMsg++
3940 this.actor.incrementTicks(10)
4041 if (ref) {
4142 this.actor.send(new Message({
@@ -44,22 +45,19 @@
4445 }))
4546 }
4647 }
4748 }
48- const tree = new RadixTree({
49- db: db
50- })
5149
52- const hypervisor = new Hypervisor(tree)
50+ const hypervisor = new Hypervisor({tree})
5351 hypervisor.registerContainer(BenchmarkContainer)
5452
5553 const refernces = []
5654 let _numOfActors = numOfActors
5755 while (_numOfActors--) {
58- const {
59- module
60- } = hypervisor.createActor(BenchmarkContainer.typeId)
61- refernces.push(module.getFuncRef('main'))
56+ const {module} = hypervisor.createActor(BenchmarkContainer.typeId)
57+ const funcRef = module.getFuncRef('main')
58+ funcRef.gas = 1000
59+ refernces.push(funcRef)
6260 }
6361 _numOfActors = numOfActors
6462 let msgs = []
6563 while (_numOfActors--) {
@@ -75,9 +73,8 @@
7573 funcRef: refernces[_numOfActors]
7674 })
7775 msgs.push(message)
7876 }
79-
8077 let start = new Date()
8178 hypervisor.send(msgs)
8279 await hypervisor.scheduler.on('idle', () => {
8380 const end = new Date() - start
egressDriver.jsView
@@ -6,8 +6,10 @@
66 super()
77 this.id = new ID(Buffer.from([0]))
88 }
99
10+ startup () {}
11+
1012 runMessage (message) {
1113 this.emit('message', message)
1214 }
1315 }
index.jsView
@@ -146,8 +146,9 @@
146146 * register a driver with the hypervisor
147147 * @param {driver} driver
148148 */
149149 registerDriver (driver) {
150+ driver.startup(this)
150151 this.scheduler.drivers.set(driver.id.toString(), driver)
151152 }
152153 }
153154
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 365133 bytes
New file size: 365090 bytes
package.jsonView
@@ -36,9 +36,9 @@
3636 "safe-buffer": "^5.1.1"
3737 },
3838 "devDependencies": {
3939 "coveralls": "^3.0.0",
40- "dfinity-radix-tree": "^0.2.1",
40+ "dfinity-radix-tree": "^0.2.2",
4141 "documentation": "^6.0.0",
4242 "level-browserify": "^1.1.2",
4343 "nyc": "^11.6.0",
4444 "standard": "11.0.1",
scheduler.jsView
@@ -39,11 +39,9 @@
3939 const message = this._messages.shift()
4040 await this._processMessage(message)
4141 }
4242 this._running = false
43- const promises = []
44- this.actors.forEach(actor => promises.push(actor.shutdown()))
45- await Promise.all(promises)
43+ this.actors.forEach(actor => actor.shutdown())
4644 this.actors.clear()
4745 this.emit('idle')
4846 }
4947
tests/index.jsView
@@ -687,8 +687,8 @@
687687 }
688688
689689 hypervisor.send(msgs)
690690 await hypervisor.scheduler.on('idle', () => {
691- t.equals(numOfMsg, 110)
691+ t.equals(numOfMsg, depth * numOfActors + numOfActors)
692692 t.end()
693693 })
694694 })

Built with git-ssb-web