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

executor: avoid initializing chunk with max chunk size in some places #50036

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #28339, #9045, #9166, #6489

Problem Summary:

What changed and how does it work?

The usage of initial chunk size is not reasonable.
Some of the code just allocate max chunks at the beginning.

One of our customer get an incident caused the large chunk allocation.
(After I go through the issues, I find the root cause is exactly the same with #28339).
They use a log of varchar(1500), varchar(3000) fields in the tables, with default max chunk size=1024, the GC pressure is too high.

In this commit, I change some of the code with inproper chunk size usage, from MaxChunkSize to InitCap.

Check List

Tests

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

Try this test and observe the object allocation size:

func BenchmarkXXX(b *testing.B) {
	store := testkit.CreateMockStore(b)
	tk := testkit.NewTestKit(b, store)
	tk.MustExec("use test;")
	tk.MustExec("drop table if exists t, s;")
	tk.MustExec("create table t(a int primary key, b int, c varchar(1500))")
	tk.MustExec("create table t1(a int, b int, c varchar(3000), key s(b))")
	tk.MustExec("insert into t values(1, 1, repeat('x', 1500)), (2, 2, repeat('y', 1500)), (3, 3, repeat('z', 1500))")
	tk.MustExec("insert into t1 values(1, 2, repeat('x', 3000)), (1, 3, repeat('y', 3000)), (1, 4, repeat('z', 3000)), (3, 4, repeat('t', 3000)), (4, 5, repeat('k', 3000))")

	b.ResetTimer()
	for i:=0; i<b.N; i++ {
		tk.MustQuery("select /*+ INL_HASH_JOIN(t, t1) */ * from t join t1 on t.a=t1.a").Sort()
	}
}

From 816232 B/op to 551738 B/op

go test -tags intest -benchtime 10s -test.run XX -test.bench BenchmarkXXX --benchmem 

Before vs After:
BenchmarkXXX-16            12745            968037 ns/op          816232 B/op       3793 allocs/op
BenchmarkXXX-16            13542            876849 ns/op          551738 B/op       3771 allocs/op
  • No need to test
    • I checked and no code files have been changed.

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

Copy link

ti-chi-bot bot commented Jan 3, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Jan 3, 2024
@tiancaiamao tiancaiamao marked this pull request as ready for review January 3, 2024 09:18
@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jan 3, 2024
Copy link

tiprow bot commented Jan 3, 2024

Hi @tiancaiamao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2024
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.9674%. Comparing base (b50b151) to head (4b77cbc).
Report is 2472 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #50036         +/-   ##
=================================================
- Coverage   71.9505%   55.9674%   -15.9832%     
=================================================
  Files          1438       1682        +244     
  Lines        345800     667613     +321813     
=================================================
+ Hits         248805     373646     +124841     
- Misses        76750     268056     +191306     
- Partials      20245      25911       +5666     
Flag Coverage Δ
integration 43.9091% <100.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.3129% <ø> (ø)
parser ∅ <ø> (∅)
br 59.0240% <ø> (+7.3994%) ⬆️

Copy link

ti-chi-bot bot commented Jan 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackysp, YangKeao

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 8, 2024
Copy link

ti-chi-bot bot commented Jan 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-03 09:24:54.16083975 +0000 UTC m=+2248985.198066676: ☑️ agreed by YangKeao.
  • 2024-01-08 03:16:58.220581277 +0000 UTC m=+240407.804834947: ☑️ agreed by jackysp.

@hawkingrei
Copy link
Member

/test all

1 similar comment
@hawkingrei
Copy link
Member

/test all

@hawkingrei
Copy link
Member

/retest

@tiancaiamao
Copy link
Contributor Author

/retest-required

Copy link

tiprow bot commented Feb 20, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@YangKeao
Copy link
Member

/retest

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Feb 29, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hawkingrei
Copy link
Member

/retest

Copy link

tiprow bot commented Apr 11, 2024

@tiancaiamao: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test 4b77cbc link true /test tiprow_fast_test
tidb_parser_test 4b77cbc link true /test tidb_parser_test
fast_test_tiprow 4b77cbc link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 7, 2024
Copy link

ti-chi-bot bot commented May 7, 2024

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

ti-chi-bot bot commented Nov 18, 2024

@tiancaiamao: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 4b77cbc link true /test unit-test
pull-integration-e2e-test 4b77cbc link true /test pull-integration-e2e-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants