-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core Refactor: Worker, MP asyncio #538
Comments
@bitfag please elaborate on
|
Thoughts on architecture:
What has to be figured out: currently the core (WorkerInfrastructure) is based on bitshares.Notify. On startup it subscribes to markets, blocks, accounts. bitshares.Notify uses websocket-client callbacks. So basically when something happening on the bitshares, Notify gets event, then it's propagated to all workers. Async variant of bitshares.Notify has to use For multiprocessing, I don't know what are you planning exactly. If you're going to run each worker as separate process, you cannot use callbacks at all. Each worker will have to use own BitShares instance and manage subscriptions on it's own. It's just like running N dexbot instances with single worker in each. I don't clearly see how exactly we can benefit from multiprocessing. What is it may be good for, is to push some long-running computations into separate processes, as laid out in this example https://docs.python.org/3/library/asyncio-eventloop.html#executing-code-in-thread-or-process-pools |
I agree on this aspect to split core and front ends re: bitshares.Notify: lets wait for xeroc if he is implementing this and see what happens As for multiprocessing, I don't think this is best way. Perhaps multithreading. |
State machine has been removed and merged into devel |
Something to consider for design.
|
A strategy can use ProcessPoolExecutor to run heavy computations not blocking the main process. https://docs.python.org/3/library/asyncio-eventloop.html#executing-code-in-thread-or-process-pools |
Ok sounds good. I'll take a look into it |
I like the queue idea for using the pybitshares instance. That will allow for maximizing throughput of one bitshares-instance. Would a step forward be to have pybitshares operate from a queue (no async yet), and separate each worker into a thread of it's own? That way workers would have a break while waiting for data, and give other workers the opportunity to add their questions to the queue. Then the earlier workers would resume. I would imagine that could speed up stuff by a factor of two, and async would yield another x10 later on. How hard would it be to make an API to separate gui from core? There's not terribly much communication going on there I guess. What kind of API would be best for enabling different frontends? A web interface over LAN or ssh would be a nice possibility, and a Telegram control too :-). |
Not sure it will worth efforts. Here is asyncio progress https://github.com/Codaone/DEXBot/projects/14 |
Hi @MarkoPaasila - This is the same thing I thought would be a temporary solution. I tried doing this last week using a threadpool (which is an extension of a thread queue) and no async, it does speed up the output but it has thread collisions from the single shared bitshares instance. What's interesting is that the thread collisions are not consistent so sometimes it takes several attempts in testing for the collisions to show up. Also tried spawning multiple bitshares instances and running them in separate processes instead of threads but this also has collision problems. see #589 (comment) The first attempt to creating multiple Bitshares() Instance, gave error is in appendSigner, where the wallet is locked and the other threads try to seize the lock at the same time. It doesn't happen every time but it can.
In other cases, for example from within SO, grapheneapi.exceptions.RPCError: Assert Exception: now <= trx.expiration:
which is linked to graphenelib transactionbuilder.py
|
see #589 , closing to avoid duplicate confusion |
Discussion on Core Refactor, originated on Telegram
Goal is to make the Worker Infrastructure for Dexbot use multiprocessing and asyncio to speed up computations on CPU and I/O.
Legacy code not used anymore
Open issues for discussion:
Interaction Diagraming and UML to be added to the TDD: Technical Design Doc
The text was updated successfully, but these errors were encountered: