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

stmtctx, *: change TypeCtx field to a private field #47742

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Oct 18, 2023

What problem does this PR solve?

Issue Number: close #47698, close #47752

Problem Summary:

What is changed and how it works?

This PR changed the TypeCtx into a private field, and provide a function TypeCtx to get the type context from statement context.

Actually I quite doubt whether copying TypeCtx for each function call will cause significant performance degradation 🤔 . This change will also make it easier/more flexible to change from TypeCtx to *TypeCtx if we found loading full TypeCtx into register (or copying in memory, if the size increases in the future) is slow (or the TypeCtx gets too big to copy) in the future.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Simple code refractor. They are covered by existing unit tests and integration tests.

@YangKeao YangKeao added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 18, 2023
@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 18, 2023
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #47742 (27e16a5) into master (3ef01b5) will increase coverage by 0.9038%.
Report is 7 commits behind head on master.
The diff coverage is 87.8260%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #47742        +/-   ##
================================================
+ Coverage   71.8893%   72.7931%   +0.9038%     
================================================
  Files          1398       1421        +23     
  Lines        405152     411584      +6432     
================================================
+ Hits         291261     299605      +8344     
+ Misses        94280      93118      -1162     
+ Partials      19611      18861       -750     
Flag Coverage Δ
integration 41.4913% <72.1739%> (?)
unit 71.8537% <77.3913%> (-0.0356%) ⬇️

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

Components Coverage Δ
dumpling 53.9913% <ø> (ø)
parser ∅ <ø> (∅)
br 48.6844% <ø> (-4.2530%) ⬇️

@@ -20,7 +20,7 @@ import (
)

// HandleTruncate ignores or returns the error based on the Context state.
func (c *Context) HandleTruncate(err error) error {
func (c Context) HandleTruncate(err error) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason to change the receiver type? I think it should keep the same with other methods

Copy link
Member Author

Choose a reason for hiding this comment

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

Both are fine. This change makes it easier to write sc.TypeCtx().HandleTruncate()...

Maybe I should add a HandleTruncate method for sc 🤔 , it sounds better.

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL, I changed it to c *Context, and add a new method HandleTruncate to the statement context.

Copy link
Contributor

Choose a reason for hiding this comment

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

that HandleTruncate has been added to the statement context, is it possible to modify https://github.com/pingcap/tidb/blob/master/pkg/types/binary_literal.go#L104C60-L104C60 to the previous version to use statement context? This currently seems to cause panic in the benchmark test #47752

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

great solution

@YangKeao YangKeao force-pushed the fix-47689 branch 2 times, most recently from 3232f31 to 88db855 Compare October 18, 2023 10:34
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 19, 2023
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 19, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 19, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-19 03:40:10.645284928 +0000 UTC m=+1887608.232395072: ☑️ agreed by lcwangchao.
  • 2023-10-19 03:50:59.439523203 +0000 UTC m=+1888257.026633348: ☑️ agreed by xhebox.

Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. do-not-merge/needs-triage-completed and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 19, 2023
@YangKeao
Copy link
Member Author

/check-issue-triage-complete

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 19, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lcwangchao, xhebox, XuHuaiyu

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 the approved label Oct 19, 2023
@YangKeao
Copy link
Member Author

/retest

A data race (not related with this PR) is detected. #47776

@ti-chi-bot ti-chi-bot bot merged commit 90bd2dd into pingcap:master Oct 19, 2023
12 of 16 checks passed
wuhuizuo pushed a commit to wuhuizuo/tidb that referenced this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
5 participants