-
Notifications
You must be signed in to change notification settings - Fork 293
improve the scheduler #989
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ def __init__( | |
| cache_port, | ||
| visual_model_rpc_ports, | ||
| ): | ||
| context = zmq.asyncio.Context(2) | ||
| context = zmq.Context(2) | ||
| self.send_to_next_module = context.socket(zmq.PUSH) # router or audio server (if --enable_multimodal_audio) | ||
| self.send_to_next_module.connect(f"{args.zmq_mode}127.0.0.1:{next_module_port}") | ||
|
|
||
|
|
@@ -150,12 +150,22 @@ async def loop_for_fwd(self): | |
| images_need_infer = [] | ||
|
|
||
| async def loop_for_netio_req(self): | ||
| if not hasattr(self, "visual_recv_max_count"): | ||
| self.visual_recv_max_count = 64 | ||
|
Comment on lines
+153
to
+154
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better practice to initialize instance attributes like Consider moving |
||
|
|
||
| while True: | ||
| recv_req: GroupReqIndexes = await self.recv_from_httpserver.recv_pyobj() | ||
| if isinstance(recv_req, GroupReqIndexes): | ||
| self.waiting_reqs.append(recv_req) | ||
| else: | ||
| assert False, f"Error Req Inf {recv_req}" | ||
| try: | ||
| for _ in range(self.visual_recv_max_count): | ||
| recv_req: GroupReqIndexes = self.recv_from_httpserver.recv_pyobj(zmq.NOBLOCK) | ||
| if isinstance(recv_req, GroupReqIndexes): | ||
| self.waiting_reqs.append(recv_req) | ||
| else: | ||
| assert False, f"Error Req Inf {recv_req}" | ||
| self.visual_recv_max_count = min(self.visual_recv_max_count * 1.3, 256) | ||
| except zmq.ZMQError: | ||
| # 当队列已经开始清空的时候,将一次接受数量下调 | ||
| self.visual_recv_max_count = 64 | ||
| await asyncio.sleep(0.01) | ||
|
|
||
| def clean_up(self): | ||
| for model_rpc in self.model_rpcs: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ZMQ context has been changed from
zmq.asyncio.Contexttozmq.Context. This is a critical issue because the sockets created from this context are used in anasyncenvironment.self.recv_from_httpserveris used withawait self.recv_from_httpserver.recv_pyobj(). A socket from a synchronous context is not awaitable and will block the event loop or raise an error.self.send_to_next_module.send_pyobj()is called from anasyncfunction. Using a blocking socket here will block the entire event loop, severely impacting performance and responsiveness.Please revert this change to use the async context.