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: improve TopSQL reporter memory efficiency #25195

Merged
merged 41 commits into from
Jun 11, 2021

Conversation

dragonly
Copy link
Contributor

@dragonly dragonly commented Jun 7, 2021

What problem does this PR solve?

Problem Summary:

The current TopSQL reporter copies data before sending to gRPC endpoint.

What is changed and how it works?

What's Changed:
Iterate data at send time to reduce a memory copy.

How it Works:
Because the SQL/plan meta could be > 1M for each record, this could potentially save some GB of memory.

Related changes

Check List

Tests

  • Unit test
  • Integration test

Side effects

None.

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 7, 2021
@dragonly
Copy link
Contributor Author

dragonly commented Jun 7, 2021

/cc @breeswish @crazycs520

@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 7, 2021
Co-authored-by: crazycs <chen.two.cs@gmail.com>
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

The rest LGTM.

@@ -28,7 +28,7 @@ import (

// ReportClient send data to the target server.
type ReportClient interface {
Send(ctx context.Context, addr string, sqlMetas []*tipb.SQLMeta, planMetas []*tipb.PlanMeta, records []*tipb.CPUTimeRecord) error
Send(ctx context.Context, addr string, data reportData, decodePlan planBinaryDecodeFunc) error
Copy link
Member

Choose a reason for hiding this comment

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

decodePlan should be a ReportClient constructor parameter.

crazycs520
crazycs520 previously approved these changes Jun 7, 2021
Copy link
Contributor

@crazycs520 crazycs520 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 added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 7, 2021
@breezewish breezewish added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 7, 2021
@crazycs520 crazycs520 dismissed their stale review June 7, 2021 08:46

need add more test and fix bugs

Signed-off-by: crazycs <crazycs520@gmail.com>
…s is instance

Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
@dragonly dragonly requested a review from a team as a code owner June 7, 2021 09:37
@dragonly dragonly requested review from wshwsh12 and removed request for a team June 7, 2021 09:37
@crazycs520
Copy link
Contributor

/run-unit-test

@github-actions github-actions bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Jun 7, 2021
@crazycs520
Copy link
Contributor

/run-all-tests

2 similar comments
@crazycs520
Copy link
Contributor

/run-all-tests

@crazycs520
Copy link
Contributor

/run-all-tests

@breezewish breezewish added needs-cherry-pick-release-5.1 and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 10, 2021
@wshwsh12 wshwsh12 removed their request for review June 11, 2021 02:40
@crazycs520
Copy link
Contributor

/run-all-tests

Signed-off-by: crazycs <crazycs520@gmail.com>
@crazycs520
Copy link
Contributor

/run-all-tests

@crazycs520
Copy link
Contributor

/run-all-tests

@crazycs520
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 1ab86ae

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 11, 2021
@crazycs520
Copy link
Contributor

/merge

@crazycs520
Copy link
Contributor

/run-all-tests

@ti-chi-bot ti-chi-bot merged commit f4e608b into pingcap:master Jun 11, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jun 11, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #25363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.1 sig/execution SIG execution sig/sql-infra SIG: SQL Infra 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.

5 participants