-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download inputs off the event consumer loop
Currently, we download inputs (via URLPath's convert() method) in _prepare_payload, in the main Worker event consumer loop. This is bad, because downloading inputs is a blocking operation and we cannot process other events while downloads are in progress. This is a substantial restructuring: - the event consumer loop now only processes events from the child; prediction requests and cancel requests from the http server are now processed directly. - there are new concurrent.future.ThreadPoolExecutor instances for preparing predictions and downloading inputs. - as part of this, this commit also supports downloading inputs concurrently rather than serially. I have hardcoded a maximum of 8 concurrent downloads based on the ThreadPoolExecutor size. I picked this number arbitrarily. - when the web server receives a request to start a prediction, we submit a task on the prediction start executor, which in turn submits downloads on the input download executor. Once all inputs are downloaded, we send the prediction request to the child. - cancel requests are handled similarly, but as there is no input download this is much simpler. - all calls to self._events.send() now happen within the http server async event loop, not the Worker ThreadPoolExecutor. (This is maybe not strictly correct, as we're calling blocking i/o from an async event loop, but it's a local Connection object and it's a tiny amount of data)
- Loading branch information
1 parent
392819d
commit f2ba468
Showing
1 changed file
with
69 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters