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

util: increase column's nullBitmap's capacity #12470

Merged
merged 7 commits into from
Oct 28, 2019

Conversation

H-ZeX
Copy link
Contributor

@H-ZeX H-ZeX commented Sep 29, 2019

Signed-off-by: H-ZeX hzx20112012@gmail.com

What problem does this PR solve?

nullBitmap's cap

The origin nullBitmap's capacity is a little small.
When the cap param is (x<<3)+y(0<y<8), the nullBitMap's len is only x, so the col that it can represent is (x<<3), which is small that the column number (x<<3)+y, then this slice need to be expanded.
For example, if there is 8+7=15 col, we need 2 bytes nullBitmap to represent it. But, 15>>3 only get 1, so this slice need to be expanded to 2 bytes.
If the slice expands, the memory usage increased is not little, so I think adding one byte to nullBitmap is better and necessary.
In util/chunk/column.go, there is many patterns like (x+7)>>3 such as

func (c *Column) appendMultiSameNullBitmap(notNull bool, num int) {
	numNewBytes := ((c.length + num + 7) >> 3) - len(c.nullBitmap)
sizeNulls := (n + 7) >> 3

What is changed and how it works?

  • x>>3 -> ((x+7)>>3)

Check List

Tests

existing unit test

Side effects

No.

Related changes

No.

Release note

TODO

Signed-off-by: H-ZeX <hzx20112012@gmail.com>
@winkyao
Copy link
Contributor

winkyao commented Sep 29, 2019

/rebuild

Signed-off-by: H-ZeX <hzx20112012@gmail.com>
@codecov
Copy link

codecov bot commented Sep 29, 2019

Codecov Report

Merging #12470 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12470   +/-   ##
===========================================
  Coverage   80.0167%   80.0167%           
===========================================
  Files           465        465           
  Lines        107330     107330           
===========================================
  Hits          85882      85882           
  Misses        14955      14955           
  Partials       6493       6493

@H-ZeX H-ZeX changed the title util: increase column's nullBitmap's capacity util: increase column's nullBitmap's capacity and change the way to shorten a slice Sep 29, 2019
@winkyao
Copy link
Contributor

winkyao commented Sep 29, 2019

/bench

1 similar comment
@H-ZeX
Copy link
Contributor Author

H-ZeX commented Sep 29, 2019

/bench

@H-ZeX
Copy link
Contributor Author

H-ZeX commented Sep 29, 2019

/bench/bench/bench/bench

Signed-off-by: H-ZeX <hzx20112012@gmail.com>
@H-ZeX H-ZeX force-pushed the fix_column_null_bitmap_too_short branch from 4d3ad5b to a00865a Compare October 10, 2019 02:42
@H-ZeX
Copy link
Contributor Author

H-ZeX commented Oct 10, 2019

/bench

1 similar comment
@H-ZeX
Copy link
Contributor Author

H-ZeX commented Oct 25, 2019

/bench

@H-ZeX
Copy link
Contributor Author

H-ZeX commented Oct 25, 2019

/run-all-tests

@H-ZeX H-ZeX changed the title util: increase column's nullBitmap's capacity and change the way to shorten a slice util: increase column's nullBitmap's capacity Oct 25, 2019
@H-ZeX
Copy link
Contributor Author

H-ZeX commented Oct 25, 2019

/bench

@sre-bot
Copy link
Contributor

sre-bot commented Oct 25, 2019

Benchmark Report

Run Sysbench Performance Test on VMs

@@                               Benchmark Diff                               @@
================================================================================
--- tidb: 4907685ed298c0efb4f09530cc7bf6c1e2843cd4
+++ tidb: c3aac21a6a9636298757c5160af81af2842476c8
tikv: 57aa7ba9edeb4132ba8bcef8ec916952ad343b0f
pd: 6e22c1c3cc7a266011d0a706a8cbfc2f6329af4a
================================================================================
oltp_update_non_index:
    * QPS: 4866.03 ± 0.22% (std=7.41) delta: 0.18% (p=0.410)
    * Latency p50: 26.30 ± 0.22% (std=0.04) delta: -0.18%
    * Latency p99: 42.45 ± 4.89% (std=1.46) delta: 0.01%
            
oltp_insert:
    * QPS: 4722.02 ± 0.03% (std=1.17) delta: 0.07% (p=0.472)
    * Latency p50: 27.10 ± 0.05% (std=0.01) delta: -0.06%
    * Latency p99: 49.45 ± 3.17% (std=1.16) delta: 0.49%
            
oltp_read_write:
    * QPS: 15596.42 ± 0.65% (std=66.71) delta: -0.62% (p=0.094)
    * Latency p50: 164.79 ± 0.29% (std=0.34) delta: 0.80%
    * Latency p99: 326.17 ± 5.31% (std=10.86) delta: 1.87%
            
oltp_update_index:
    * QPS: 4367.49 ± 0.22% (std=6.79) delta: 0.16% (p=0.556)
    * Latency p50: 29.31 ± 0.23% (std=0.05) delta: -0.16%
    * Latency p99: 55.59 ± 4.10% (std=1.49) delta: 2.00%
            
oltp_point_select:
    * QPS: 42509.41 ± 0.89% (std=237.23) delta: -0.67% (p=0.128)
    * Latency p50: 3.01 ± 1.00% (std=0.02) delta: 0.75%
    * Latency p99: 9.48 ± 0.90% (std=0.08) delta: 0.91%
            

@XuHuaiyu XuHuaiyu added the type/enhancement The issue or PR belongs to an enhancement. label Oct 28, 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 the status/LGT1 Indicates that a PR has LGTM 1. label Oct 28, 2019
@XuHuaiyu
Copy link
Contributor

PTAL @qw4990

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason 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 Oct 28, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 28, 2019

Your auto merge job has been accepted, waiting for 12862

@sre-bot
Copy link
Contributor

sre-bot commented Oct 28, 2019

/run-all-tests

@sre-bot sre-bot merged commit b3ad90e into pingcap:master Oct 28, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 28, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 28, 2019

cherry pick to release-3.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 28, 2019

cherry pick to release-3.0 failed

@H-ZeX H-ZeX deleted the fix_column_null_bitmap_too_short branch October 28, 2019 14:43
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @XuHuaiyu PTAL.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 8, 2020

/run-cherry-picker

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 8, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-3.0 in PR #16141

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 8, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-3.1 in PR #16142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/util status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants