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: some minor refine for hash join v2 build #54429

Conversation

windtalker
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #53127

Problem Summary:

What changed and how does it work?

  1. During hash join v2 build, it will pre-allocate maxRowTableSegmentSize(which is 1024) rows for a new rowTableSegment

    func newRowTableSegment() *rowTableSegment {
    return &rowTableSegment{
    // TODO: @XuHuaiyu if joinKeyIsInlined, the cap of rawData can be calculated
    rawData: make([]byte, 0),
    hashValues: make([]uint64, 0, maxRowTableSegmentSize),
    rowStartOffset: make([]uint64, 0, maxRowTableSegmentSize),
    validJoinKeyPos: make([]int, 0, maxRowTableSegmentSize),
    }
    }

    For small queries, it is a waste to pre allocate so many memories and may hurt the performance in high concurrency scenarios.
    In this pr, when constructing a new rowTableSegment, it will use chunk_row_number/partition_number * 1.2 as the row size hint for the first rowTableSegment, but still use maxRowTableSegmentSize as the row size hint for the following rowTableSegment.

  2. Add maxRowTableSegmentByteSize to control the max memory size of a rowTableSegment.

  3. Since rowTableSegment saves rowStartOffset directly, there is no need to save row offset in builder.startPosInRawData, so remove startPosInRawData in rowTableBuilder

  4. rename crrntSizeOfRowTable to rowNumberInCurrentRowTableSeg

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.

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 4, 2024
Copy link

tiprow bot commented Jul 4, 2024

Hi @windtalker. 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-sigs/prow repository.

@xzhangxian1008
Copy link
Contributor

/assign

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.

Project coverage is 55.0895%. Comparing base (a48a4a2) to head (2ef007d).

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54429         +/-   ##
=================================================
- Coverage   72.6973%   55.0895%   -17.6078%     
=================================================
  Files          1551       1672        +121     
  Lines        437184     609272     +172088     
=================================================
+ Hits         317821     335645      +17824     
- Misses        99756     250669     +150913     
- Partials      19607      22958       +3351     
Flag Coverage Δ
integration 19.9170% <0.0000%> (?)

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.4834% <ø> (+6.6429%) ⬆️

Copy link
Contributor

@xzhangxian1008 xzhangxian1008 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 the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 5, 2024
Copy link

ti-chi-bot bot commented Jul 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XuHuaiyu, xzhangxian1008

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 8, 2024
Copy link

ti-chi-bot bot commented Jul 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-05 03:03:10.663133375 +0000 UTC m=+1552717.148622205: ☑️ agreed by xzhangxian1008.
  • 2024-07-08 06:37:39.268194276 +0000 UTC m=+253156.503428389: ☑️ agreed by XuHuaiyu.

@hawkingrei
Copy link
Member

/retest

…or small query

Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
@windtalker windtalker force-pushed the hash_join_v2_not_preallocate_too_many_memory branch from 8aa9eff to 9df10ef Compare July 18, 2024 01:53
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
@ti-chi-bot ti-chi-bot bot merged commit e858f55 into pingcap:master Jul 18, 2024
21 checks passed
@windtalker windtalker deleted the hash_join_v2_not_preallocate_too_many_memory branch July 22, 2024 02:06
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants