pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.86k stars 5.8k forks source link

Parallel building cop tasks with cop workers in TiKV client. (select * from limit 1 is too slow) #14320

Open SunRunAway opened 4 years ago

SunRunAway commented 4 years ago

Description

The current procedure when sending a cop request is

  1. build all cop tasks in memory.
  2. send each cop task to copIteratorWorker
  3. copIteratorWorker execute the task

If we have thousands of tasks, the building step may take too long(and it may load region info from pd), it will enlarge the time of first meeting row.

We need build all cop tasks in a diffrent goroutine, and send tasks which successfully builded immediately to copIteratorWorker.

  1. For OLTP SQLs, it would be better build first 1 or 2 tasks in the same goroutine, then create a new goroutine to build the rest.
  2. We can fix this issue when the request need an asending order firstly.
  3. If the request need a desending order response, it may takes extra works on this issue. (We may need implement a desending spliting range method)

Difficulty

Score

Mentor(s)

Recommended Skills

ekalinin commented 4 years ago

/pick-up-challenge

sre-bot commented 4 years ago

@ekalinin already had picked pingcap/tidb#12939, finish it before pick up a new one.

ekalinin commented 4 years ago

/pick-up-challenge

sre-bot commented 4 years ago

@ekalinin pick up issue success

SunRunAway commented 4 years ago

Hi @ekalinin , Thank you for picking this chanllenge. Do you have any ideas or plans? Feel free to ask me anything here or on slack.

ekalinin commented 4 years ago

Hi @ekalinin , Thank you for picking this chanllenge. Do you have any ideas or plans? Feel free to ask me anything here or on slack.

Hi @SunRunAway

Yes, i'm working on this issue it the moment. Current plan is:

Current state: did almost all steps, except last one (copIterator.Next). And a lot of tests are failing at the moment.

SunRunAway commented 4 years ago

👍 Sounds great, looking forward your pull request.

SunRunAway commented 4 years ago

@fzhedu PTAL when you're free, Thanks.

you06 commented 2 months ago

After #53850, both tiflash and tikv coprocessor load the region info in batch from PD, building all the cop tasks no more taks a long time, I think this issue can be closed.