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

*: Chunkreuse try reuse chunk in operator #38607

Merged
merged 86 commits into from
Nov 4, 2022

Conversation

keeplearning20221
Copy link
Contributor

@keeplearning20221 keeplearning20221 commented Oct 22, 2022

What problem does this PR solve?

Issue Number: close #38606

Problem Summary:
Every time chunk is used, it will be applied from the system, which affects the execution efficiency of tidb-server.

What is changed and how it works?

Cache previously applied chunks and columns in alloc.later, it will get chunk from cache first , if not enough then apply from system.
Alloc modified based on the alloc developed by tiancaiamao. It uses slices to manage chunks objects and columns objects. When used, they are taken out of free slices and placed in allocated slices.When the SQL execution is complete, put it back from the allocated slice back to the free slice.
Add configuration items
tidb_enable_reuse_chunk function switch
tidb_max_reuse_chunk Maximum number of cached chunks
tidb_max_reuse_column Maximum number of cached columns
Add read-only variable:
Last_sql_use_alloc Whether the previous sql uses chunk alloc

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

	modified:   distsql/select_result.go
	modified:   executor/adapter.go
	modified:   executor/admin.go
	modified:   executor/aggregate.go
	modified:   executor/builder.go
	modified:   executor/coprocessor.go
        modified:   executor/cte.go
	modified:   executor/delete.go
	modified:   executor/distsql.go
	modified:   executor/executor.go
	modified:   executor/explain.go
	modified:   executor/index_lookup_hash_join.go
	modified:   executor/index_lookup_join.go
	modified:   executor/index_lookup_merge_join.go
	modified:   executor/index_merge_reader.go
	modified:   executor/insert_common.go
	modified:   executor/join.go
	modified:   executor/joiner.go
	modified:   executor/merge_join.go
	modified:   executor/parallel_apply.go
	modified:   executor/pipelined_window.go
	modified:   executor/projection.go
	modified:   executor/select_into.go
	modified:   executor/show.go
	modified:   executor/shuffle.go
	modified:   executor/sort.go
	modified:   executor/union_scan.go
	modified:   executor/update.go
	modified:   executor/window.go
	modified:   server/conn.go
	modified:   sessionctx/variable/session.go
	modified:   sessionctx/variable/sysvar.go
	modified:   sessionctx/variable/tidb_vars.go
	modified:   util/chunk/alloc.go
	modified:   util/chunk/alloc_test.go
	modified:   util/chunk/chunk.go
…into chunkreuse

Conflicts:
	executor/adapter.go
	executor/aggregate.go
	executor/builder.go
	executor/coprocessor.go
	executor/distsql.go
	executor/executor.go
	executor/join.go
	executor/projection.go
	executor/union_scan.go
	executor/update.go
	sessionctx/variable/session.go
	util/chunk/alloc.go

	modified:   executor/executor.go
	modified:   executor/index_lookup_merge_join.go
	modified:   sessionctx/variable/session.go
	modified:   executor/parallel_apply.go
	modified:   sessionctx/variable/session.go
	modified:   util/chunk/alloc.go
	modified:   util/chunk/chunk.go
	modified:   executor/admin.go
	modified:   executor/aggregate.go
	modified:   executor/distsql.go
	modified:   executor/executor.go
	modified:   executor/index_lookup_hash_join.go
	modified:   executor/index_lookup_join.go
	modified:   executor/index_lookup_merge_join.go
	modified:   executor/index_merge_reader.go
	modified:   executor/join.go
	modified:   executor/joiner.go
	modified:   executor/pipelined_window.go
	modified:   server/conn.go
	modified:   sessionctx/variable/sysvar.go
	modified:   sessionctx/variable/tidb_vars.go
	modified:   util/chunk/alloc.go
@keeplearning20221 keeplearning20221 requested a review from a team as a code owner October 22, 2022 08:26
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • tiancaiamao

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 22, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 22, 2022
@hawkingrei
Copy link
Member

@keeplearning20221 Please fix the linter.

	modified:   util/chunk/alloc.go
	modified:   util/chunk/chunk.go
	modified:   util/chunk/chunk.go
	modified:   sessionctx/variable/tidb_vars.go
	modified:   executor/index_lookup_merge_join.go
	modified:   util/chunk/alloc_test.go
	modified:   util/chunk/alloc_test.go
@keeplearning20221
Copy link
Contributor Author

/run-build

@keeplearning20221
Copy link
Contributor Author

/run-unit-test

@keeplearning20221
Copy link
Contributor Author

/run-build

	modified:   sessionctx/variable/session_test.go
	modified:   util/chunk/alloc.go
	modified:   util/chunk/alloc_test.go
	modified:   util/chunk/chunk_test.go
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 24, 2022
Copy link
Contributor

@cfzjywxk cfzjywxk left a comment

Choose a reason for hiding this comment

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

Perhaps related regression tests and bechmark tests are needed as it would be enabled by default.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 3, 2022
@keeplearning20221
Copy link
Contributor Author

/build-release

@keeplearning20221
Copy link
Contributor Author

/release

@tiancaiamao
Copy link
Contributor

Perhaps related regression tests and bechmark tests are needed as it would be enabled by default.

We can change to disable by default if we find anything wrong during test.

@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0ceee0d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 4, 2022
@keeplearning20221
Copy link
Contributor Author

/run-build

@keeplearning20221
Copy link
Contributor Author

/run-check_dev_2

@keeplearning20221
Copy link
Contributor Author

/run-mysql-test

@keeplearning20221
Copy link
Contributor Author

/run-unit-test

@keeplearning20221
Copy link
Contributor Author

/run-check_dev_2

@ti-chi-bot ti-chi-bot merged commit 0b3e1e9 into pingcap:master Nov 4, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Nov 4, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [2] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🔴 failed 5, success 34, total 39 31 min Existing failure
idc-jenkins-ci-tidb/common-test 🔴 failed 1, success 10, total 11 10 min Existing failure
idc-jenkins-ci-tidb/integration-ddl-test ✅ all 6 tests passed 30 min Fixed
idc-jenkins-ci-tidb/integration-common-test ✅ all 17 tests passed 16 min Fixed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 37 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 6 min 26 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 57 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 2 min 58 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 48 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chunk: reuse tidb chunk
9 participants