Closed edavalosanaya closed 1 year ago
Created benchmarks for node creation from the Worker
's NodeHandlerService
and the Manager
's WorkerHandlerService
. These are the average times:
Node Handler
(singe)
Create time: 0.23887269528006072
Destroy time: 1.9214153029000136
(10)
Create time: 0.5530374649000805
Destroy time: 12.352607617899775
Worker Handler
(single)
Create time: 0.9725189961399974
Destroy time: 2.345808336850014
(10)
Create time: 10.788499685900002
Destroy time: 23.04709231760007
It seems like the WorkerHandlerService
is not working correct when creating multiple nodes. Need to determine why.
This is the latest benchmark results (after successful tests)
Node Handler
(10)
Create time: 0.382928
Destroy time: 0.012464
Worker Handler
(10)
Create time: 0.900446
Destroy time: 0.322753
Closes #233
Objective
This PR aims to make the
Node
creation and destruction (along with otherNode
operations like P2P connections) operations yield better speed and performance. This meant using anExecutor
to haveasync
methods to control subprocess start and stop. Previously we would useAsyncLoopThread
as a bridge to combine sync/async APIs. However, this had the negative affect of multiple eventloops that cannotawait
other eventloop's tasks. This prevented the re-use of resources, likeaiohttp.ClientSession
. Through this refactoring, a single eventloop can be used and resources are better managed.TODO:
Major Breaking Changes:
Before using a
Manager
orWorker
instance, it is now required to runaserve
orserve
to start their services. This change was necessary to make async version of theManager
/Worker
use the pre-existing eventloop and avoid resource duplication, asawait
cannot be used within a__init__.py
.Before
After
Minor Breaking Changes
This
aserve/serve
change also affect theNode
-- this should not affect external dependencies that much, but it does impact an approach to debugging theNode
implementations.Before
After