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

Storages: support building vector index for ColumnFileTiny (Part 3) #9547

Merged
merged 7 commits into from
Oct 31, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Oct 21, 2024

What problem does this PR solve?

Issue Number: ref #9600

Problem Summary:

What is changed and how it works?

This PR is part of https://github.com/tidbcloud/tiflash-cse/pull/293, which introduces the read path and adds unit tests.


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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 21, 2024
@Lloyd-Pottiger Lloyd-Pottiger force-pushed the cf-tiny-vector-index-2 branch 2 times, most recently from e52552a to c91afcc Compare October 25, 2024 08:27
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.

Great work

Comment on lines 338 to 340
std::vector<Key> keys(result.size());
std::vector<Distance> distances(result.size());
result.dump_to(keys.data(), distances.data());
Copy link
Member

@breezewish breezewish Oct 29, 2024

Choose a reason for hiding this comment

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

Actually you can access each result element directly without dumping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To keep it simple and save memory.

Copy link
Member

@breezewish breezewish Oct 29, 2024

Choose a reason for hiding this comment

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

Oh, I mean you can have VectorIndexViewer::SearchResult without double copying, like this maybe:

const size_t result_size = result.size();
std::vector<SearchResult> search_results;
search_results.reserve(result_size);
for (size_t i = 0; i < result_size; ++i) {
    const auto rowid = result[i].member.key;
    if (valid_rows[rowid])
        search_results.emplace_back({ rowid, result[i].distance }); 
}

In this way we only have one round of copying, instead of two rounds.

const auto key = fmt::format(
"{}{}_{}",
VectorIndexCache::COLUMNFILETINY_INDEX_NAME_PREFIX,
tiny_file.keyspace_id,
Copy link
Member

Choose a reason for hiding this comment

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

Not sure whether store_id, table_id is also needed @JaySon-Huang

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think index_page_id is enough. Each node has it's own vec_index_cache, and it only caches the local index page.

@breezewish
Copy link
Member

The rest LGTM

Copy link
Member

@CalvinNeo CalvinNeo 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 30, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Signed-off-by: Lloyd-Pottiger <[email protected]>
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

ti-chi-bot bot commented Oct 30, 2024

@CalvinNeo: Your lgtm message is repeated, so it is ignored.

In response to this:

lgtm

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
Contributor

ti-chi-bot bot commented Oct 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, CalvinNeo

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 [CalvinNeo,breezewish]

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 Oct 31, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-30 08:24:11.013044195 +0000 UTC m=+424563.852199736: ☑️ agreed by CalvinNeo.
  • 2024-10-31 02:27:00.952504506 +0000 UTC m=+489533.791660052: ☑️ agreed by breezewish.

@ti-chi-bot ti-chi-bot bot merged commit 993d8c7 into pingcap:master Oct 31, 2024
5 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the cf-tiny-vector-index-2 branch October 31, 2024 02:34
yibin87 pushed a commit to yibin87/tiflash that referenced this pull request Oct 31, 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants