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) #16142

Merged
merged 5 commits into from
Apr 9, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Apr 8, 2020

cherry-pick #12470 to release-3.1


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: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 8, 2020

/run-all-tests

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 8, 2020

/run-all-tests

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 the status/LGT1 Indicates that a PR has LGTM 1. label Apr 8, 2020
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/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 Apr 9, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 9, 2020

Your auto merge job has been accepted, waiting for 16138, 16003, 16141, 16146

@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 9, 2020

/run-all-tests

@sre-bot sre-bot merged commit 80924b8 into pingcap:release-3.1 Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/util sig/execution SIG execution 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. type/3.1-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants