-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Make Edge Worker using async loop #56457
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
base: main
Are you sure you want to change the base?
Make Edge Worker using async loop #56457
Conversation
16dce9a to
e5de8ad
Compare
e5de8ad to
5a0ef71
Compare
|
That will be a nice improvement @jscheffl. Looking forward to this! |
|
I've just checked the code and I saw maybe a possible "improvement" regarding following code in worker: We could encapsulate the checks of the state in the WorkerInfo dataclass through properties, then above code would be easier to read and to test also, as then you can test the check of state directly in the WorkerInfo dataclass. So I would add following properties in WorkerInfo dataclass: Then you could rewrite following as below and add dedicated tests in WorkerInfo dataclass for above properties: WDYT? |
Yes, the code is not perfect and the state management has grown over time. I am also not 100% happy about it, if you have a good idea and some time... like with all: contributions are welcome. |
ad8fc74 to
53921f2
Compare
|
Really like the refactorings being done here, looking forward to test it once it's done ;-) |
|
Almost ready to review, need to hunt for one bug that I saw (and had no time, was distracted by family) hope I can make it ready for review by EOB today. |
53921f2 to
507ba20
Compare
So far the Edge worker running remote is using a single threaded loop to fetch, process, monitor tasks and upload results logs as well as heartbeat. This limits the parallelism achieveable on a Edge Worker - how many tasks can be handled in parallel.
With this PR a major refactor is made to use Python AsyncIO for handling of tasks in order to improve concurrency with many tasks.
Note: Before merging this needs to have proper review and testing as a lot of logic and libraries change with the risk of degraded quality/stability as of implementation glitched. UPDATE: WIP status left, did a lot of (local) testing and I think it is ready now.
Tested with 100 concurrent tasks (mostly sleeping) on my machine and worker used only 10-20% of CPU (compared to 10GB RAM all the task needed). So with the re-implementation in AsyncIO the worker scales very much more than before where I considered 10-15 tasks can be handled.
FYI @dheerajturaga - As also being a user, committer status still pending but looking forward for a review!
@dabla As you do a lot of AsyncIO on your side, looking forward for a review from you as well!
@AutomationDev85 - Would also like your feedback!