Skip to content
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

*: Support required rows rows for arrow decode format. #12613

Merged
merged 55 commits into from Nov 5, 2019

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Oct 11, 2019

What problem does this PR solve?

When using arrow format to decode data, it appends all data into one chunk.
It may cause that a chunk save too many things.
In this pr, support required rows for arrow decode format.

What is changed and how it works?

Add a struct ArrowDecoder to deal with the detail when append required rows to the returned chunk.

  1. Use the data bytes slice to build a chunk in the struct. (Memory reuse, really fast)
  2. Append required rows data from the struct to the returned chunk, and record the information that how many data has been used.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

Release note

Benchmark

BenchmarkSelectResponseChunk_SmallResponse-8        3006            397800 ns/op
BenchmarkSelectResponseChunk_SmallResponse_master-8   	    2949	    414161 ns/op
BenchmarkSelectResponseChunk_BigResponse-8   	     868	   1360729 ns/op
BenchmarkSelectResponseChunk_BigResponse_master-8   	     872	   1370129 ns/op

name                               old time/op  new time/op  delta
SelectResponseChunk_BigResponse-8  1.40ms ± 1%  1.41ms ± 3%   ~     (p=0.690 n=5+5)
SelectResponseChunk_SmallResponse-8   386µs ± 3%   405µs ± 1%  +4.94%  (p=0.008 n=5+5)

TPCH 50G

Version:
tidb: 5340e177b6be541f2981a9e29b7bf7a3625f7826(master) 2019-11-03 06:46:04
tikv: 086056fabd7f4763d111856854ed18f6ec9bd9da(master) 2019-11-03 02:28:24
pd: ba01076ee005b5545d679dd903f2674416176f09(master) 2019-11-01 09:12:47

Compare:
tidb: https://github.com/pingcap/tidb/compare/11cd41d...5340e17
tikv: https://github.com/tikv/tikv/compare/292ce44...086056f
pd: https://github.com/pingcap/pd/compare/ba01076...ba01076

01.sql elapsed_ms: 67776.55 ± 0.2802% (std=144.05) delta: 0.24%
02.sql elapsed_ms: 21576.88 ± 0.4347% (std=58.89) delta: -0.02%
03.sql elapsed_ms: 80073.02 ± 1.6410% (std=1017.39) delta: 0.05%
04.sql elapsed_ms: 38953.94 ± 1.5387% (std=474.05) delta: 0.57%
06.sql elapsed_ms: 44458.88 ± 0.2088% (std=63.58) delta: -0.82%
07.sql elapsed_ms: 61915.68 ± 0.4960% (std=185.78) delta: -1.17%
08.sql elapsed_ms: 65450.44 ± 0.9757% (std=450.77) delta: 1.53%
09.sql elapsed_ms: 136934.56 ± 2.1912% (std=2104.63) delta: -2.93%
10.sql elapsed_ms: 55088.41 ± 0.4401% (std=164.90) delta: -0.42%
11.sql elapsed_ms: 12339.98 ± 1.6768% (std=127.05) delta: -0.01%
12.sql elapsed_ms: 52506.32 ± 2.2628% (std=733.97) delta: -0.82%
13.sql elapsed_ms: 49567.83 ± 1.4129% (std=462.97) delta: 0.80%
14.sql elapsed_ms: 48402.44 ± 1.6835% (std=496.35) delta: -0.85%
15.sql elapsed_ms: 70156.01 ± 0.0742% (std=37.20) delta: -1.41%
16.sql elapsed_ms: 28360.51 ± 1.2965% (std=308.93) delta: -1.22%
17.sql elapsed_ms: 121267.60 ± 0.8500% (std=841.52) delta: -1.90%
18.sql elapsed_ms: 232786.07 ± 2.4822% (std=4084.29) delta: 0.45%
19.sql elapsed_ms: 54810.48 ± 0.3490% (std=123.62) delta: -0.82%
20.sql elapsed_ms: 53344.90 ± 1.2403% (std=450.87) delta: -0.98%
21.sql elapsed_ms: 96147.97 ± 0.3220% (std=263.72) delta: -0.68%
22.sql elapsed_ms: 21674.11 ± 2.1520% (std=308.77) delta: -3.76%

@codecov
Copy link

codecov bot commented Oct 11, 2019

Codecov Report

Merging #12613 into master will decrease coverage by 0.0044%.
The diff coverage is 93.9024%.

@@               Coverage Diff                @@
##             master     #12613        +/-   ##
================================================
- Coverage   80.0972%   80.0927%   -0.0045%     
================================================
  Files           468        468                
  Lines        110814     110794        -20     
================================================
- Hits          88759      88738        -21     
- Misses        15200      15201         +1     
  Partials       6855       6855

@XuHuaiyu
Copy link
Contributor

  1. Does TiKV split the data into multiple byte slices when returning to TiDB?
  2. Is there any test result that shows how much performance regression or improvement after this commit?

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Nov 1, 2019

/run-all-tests

@zyxbest
Copy link
Contributor

zyxbest commented Nov 1, 2019

/run-mybatis-test

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider rearrange our benchmark targeting SelectResponse, writing two benchmark functions BenchmarkSelectResponseArror_BigResponse and BenchmarkSelectResponseArror_SmallResponse is ok.

util/chunk/codec.go Outdated Show resolved Hide resolved
distsql/distsql_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SunRunAway SunRunAway added status/LGT1 Indicates that a PR has LGTM 1. type/enhancement labels Nov 5, 2019
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XuHuaiyu XuHuaiyu added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 5, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 5, 2019

Your auto merge job has been accepted, waiting for 12669

@sre-bot
Copy link
Contributor

sre-bot commented Nov 5, 2019

/run-all-tests

@sre-bot sre-bot merged commit e434442 into pingcap:master Nov 5, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
@wshwsh12 wshwsh12 deleted the requested_rows branch April 21, 2020 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/coprocessor status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants