code: func fetchMorePendingRequests(
  	ch chan *batchCommandsEntry,
  	maxBatchSize int,
  	batchWaitSize int,
  	maxWaitTime time.Duration,
  	entries *[]*batchCommandsEntry,
  	requests *[]*tikvpb.BatchCommandsRequest_Request,
  ) {
  	waitStart := time.Now()
  
  	// Try to collect `batchWaitSize` requests, or wait `maxWaitTime`.
  	after := time.NewTimer(maxWaitTime)
  	for len(*entries) < batchWaitSize {
  		select {
  		case entry := <-ch:
  			if entry == nil {
  				return
  			}
  			*entries = append(*entries, entry)
  			*requests = append(*requests, entry.req)
  		case waitEnd := <-after.C:
  			metrics.TiKVBatchWaitDuration.Observe(float64(waitEnd.Sub(waitStart)))
  			return
  		}
  	}
  	after.Stop()
  
  	// Do an additional non-block try. Here we test the lengh with `maxBatchSize` instead
  	// of `batchWaitSize` because trying best to fetch more requests is necessary so that
  	// we can adjust the `batchWaitSize` dynamically.
  	for len(*entries) < maxBatchSize {
  		select {
  		case entry := <-ch:
  			if entry == nil {
  				return
  			}
  			*entries = append(*entries, entry)
  			*requests = append(*requests, entry.req)
  		default:
  			metrics.TiKVBatchWaitDuration.Observe(float64(time.Since(waitStart)))
  			return
  		}
  	}
  }
docs: // fetchMorePendingRequests fetches more pending requests from the channel.