-
Notifications
You must be signed in to change notification settings - Fork 252
Description
Currently, the KV client only provides synchronous API for sending requests. If a query needs to issue multiple requests concurrently, it inevitably has to create a new goroutine for each concurrent procedure. A typical scenario is batch-get, which groups keys into batches based on regions. When the number of batches exceeds one, a worker goroutine is created for each batch to send KV requests.
We aim to reduce the number of goroutines while still allowing requests to be issued concurrently as before. To achieve this, we need to introduce async API. In fact, the internal batch client processes requests and responses asynchronously through send loop and recv loop. It's not difficult to implement an async method for RPCClient, but rewriting upper layer in an async way require a significant amount of work. This issue tries to describe the brief work plan, it's also used to track related PRs.
Here is the related task breakdown
- Define and implement core interfaces (eg. executor, callback) that will be used in async API.
- Implement
SendRequestAsyncforRPCClientand its upper wrappers (eg. collapse client, interceptor client). - Refactor
RegionRequestSenderto maximize code reuse when implementing the asynchronous interface. - Implement
SendReqAsyncforRegionRequestSender. - Refactor batch-get related methods in
KVSnapshotand allow batch-get to execute asynchronously.
Bugfixes: