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

Add insertMany interface for IColumn #8925

Merged
merged 6 commits into from
Apr 11, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Apr 10, 2024

What problem does this PR solve?

Issue Number: ref #8904

Problem Summary:

What is changed and how it works?

I used insertManyFrom in #8854, where the source column is a const column while the target column is not and it causes #8904. To fix this, add insertMany interface to avoid convert const column to full column.

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

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 Apr 10, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
virtual void insertDisjunctFrom(const IColumn & src, const std::vector<size_t> & position_vec) = 0;

/// Appends one field multiple times. Can be optimized in inherited classes.
virtual void insertMany(const Field & field, size_t length)
Copy link
Contributor

Choose a reason for hiding this comment

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

May reduce virtual function call like this:

template <typename Derived>
std::vector<MutablePtr> scatterImpl(ColumnIndex num_columns, const Selector & selector) const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be called as IColumn->insertMany(v)

Copy link
Contributor

@yibin87 yibin87 Apr 10, 2024

Choose a reason for hiding this comment

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

Yeah, the insert virutal function is called inside the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

compiler can help optimize this, no vtable lookup here https://gcc.godbolt.org/z/Y48rMoqqc

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so, think like this: different derived instances can call insertMany function, thus optimizer can't infer which insert function to be called next. Thus optimizer should lookup the vtable of current instance to find the actual insert function address. That's what "call qword ptr [rax + 8]" do, I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, I think it is ok to improve it later.

Copy link
Contributor

@yibin87 yibin87 left a comment

Choose a reason for hiding this comment

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

Others LGTM

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 10, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
Copy link
Contributor

@JaySon-Huang JaySon-Huang 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 lgtm label Apr 10, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, yibin87

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:
  • OWNERS [JaySon-Huang,yibin87]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 10, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-10 03:20:14.222976069 +0000 UTC m=+1018875.750516618: ☑️ agreed by yibin87.
  • 2024-04-10 07:00:16.197167048 +0000 UTC m=+1032077.724707586: ☑️ agreed by JaySon-Huang.

@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@Lloyd-Pottiger
Copy link
Contributor Author

/run-unit-test

@Lloyd-Pottiger Lloyd-Pottiger mentioned this pull request Apr 10, 2024
12 tasks
@Lloyd-Pottiger
Copy link
Contributor Author

/run-unit-test

Copy link
Contributor

ti-chi-bot bot commented Apr 10, 2024

@Lloyd-Pottiger: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

trigger some heavy tests which will not run always when PR updated.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@JaySon-Huang
Copy link
Contributor

/run-unit-test

@Lloyd-Pottiger
Copy link
Contributor Author

/run-integration-test

1 similar comment
@Lloyd-Pottiger
Copy link
Contributor Author

/run-integration-test

@Lloyd-Pottiger
Copy link
Contributor Author

/run-integration-test

@yibin87
Copy link
Contributor

yibin87 commented Apr 11, 2024

Caused by my tidb PR, pingcap/tidb#52143, I'm fixing it now. Maybe you can temporarily bypass this case to pass the integration tests.

Signed-off-by: Lloyd-Pottiger <[email protected]>
@yibin87
Copy link
Contributor

yibin87 commented Apr 11, 2024

/run-all-tests

@ti-chi-bot ti-chi-bot bot merged commit df29f84 into pingcap:master Apr 11, 2024
6 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the add-insert-many branch April 12, 2024 02:45
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