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

storage: Refine local index for more index kinds #9774

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Jan 7, 2025

What problem does this PR solve?

Issue Number: ref #9032

Problem Summary:

What is changed and how it works?

In order to accept more index kinds like FullTextIndex, this PR made some refactors to some persisted data:

  • Refactor DMFile proto to accept more index kinds, and extract common properties like index id and index size.
  • Refactor ColumnFileTiny proto as above.
  • Refactor ColumnFileTiny Remote proto in disaggregated mode. The new impl keeps LocalIndex information exactly the same as ColumnFileTiny local proto.
  • Remove VectorIndexKind (which is HNSW), because we will only envolve and develop one index (and will be renamed to something like AUTOINDEX).
  • Rename XxxVectorIndexWriter → XxxLocalIndexWriter (because it can build other indexes later)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test

Old data compatibility test:

# Start a cluster using current nightly
tiup playground nightly --tag vector_test

# Import data use tidb-vector-bench, compact, import data anagin

# Verify there is delta layer local index:
mysql> select * from information_schema.tiflash_indexes;
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+
| TIDB_DATABASE | TIDB_TABLE | TABLE_ID | COLUMN_NAME | INDEX_NAME  | COLUMN_ID | INDEX_ID | INDEX_KIND | ROWS_STABLE_INDEXED | ROWS_STABLE_NOT_INDEXED | ROWS_DELTA_INDEXED | ROWS_DELTA_NOT_INDEXED | ERROR_MESSAGE | TIFLASH_INSTANCE |
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+
| test          | sample     |      110 | vec         | vec_idx_vec |         2 |        1 | HNSW       |               60000 |                       0 |              60000 |                      0 |               | 127.0.0.1:3930   |
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+

Explain analyze:
tiflash_task:{time:20.7ms, loops:1, threads:14}, vector_idx:{load:{total:0ms,from_s3:0,from_disk:0,from_cache:1},search:{total:0ms,visited_nodes:191,discarded_nodes:0},read:{vec_total:0ms,others_total:0ms}}, tiflash_scan:{mvcc_input_rows:120000, mvcc_input_bytes:2040000, mvcc_output_rows:120000, local_regions:1, remote_regions:0, tot_learner_read:0ms, region_balance:{instance_num: 1, max/min: 1/1=1.000000}, delta_rows:60000, delta_bytes:1980000, segments:1, stale_read_regions:0, tot_build_snapshot:0ms, tot_build_bitmap:4ms, tot_build_inputstream:4ms, min_local_stream:15ms, max_local_stream:16ms, dtfile:{data_scanned_rows:60000, data_skipped_rows:0, mvcc_scanned_rows:60000, mvcc_skipped_rows:0, lm_filter_scanned_rows:0, lm_filter_skipped_rows:0, tot_rs_index_check:0ms, tot_read:0ms}} | keep order:false, stats:pseudo, annIndex:L2(vec..

# Restart the cluster using binary from this PR
tiup playground nightly --tag vector_test --tiflash.binpath ~/Work/tiflash/cmake-build-Release/dbms/src/Server/tiflash

# Verify again
mysql> select * from information_schema.tiflash_indexes;
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+
| TIDB_DATABASE | TIDB_TABLE | TABLE_ID | COLUMN_NAME | INDEX_NAME  | COLUMN_ID | INDEX_ID | INDEX_KIND | ROWS_STABLE_INDEXED | ROWS_STABLE_NOT_INDEXED | ROWS_DELTA_INDEXED | ROWS_DELTA_NOT_INDEXED | ERROR_MESSAGE | TIFLASH_INSTANCE |
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+
| test          | sample     |      110 | vec         | vec_idx_vec |         2 |        1 | Vector     |               60000 |                       0 |              60000 |                      0 |               | 127.0.0.1:3930   |
+---------------+------------+----------+-------------+-------------+-----------+----------+------------+---------------------+-------------------------+--------------------+------------------------+---------------+------------------+

Explain analyze:
tiflash_task:{time:28.8ms, loops:1, threads:14}, vector_idx:{load:{total:0ms,from_s3:0,from_disk:0,from_cache:1},search:{total:0ms,visited_nodes:191,discarded_nodes:0},read:{vec_total:0ms,others_total:0ms}}, tiflash_scan:{mvcc_input_rows:127000, mvcc_input_bytes:2159000, mvcc_output_rows:127000, local_regions:2, remote_regions:0, tot_learner_read:4ms, region_balance:{instance_num: 1, max/min: 2/2=1.000000}, delta_rows:67000, delta_bytes:2211000, segments:1, stale_read_regions:0, tot_build_snapshot:0ms, tot_build_bitmap:7ms, tot_build_inputstream:8ms, min_local_stream:19ms, max_local_stream:20ms, dtfile:{data_scanned_rows:60000, data_skipped_rows:0, mvcc_scanned_rows:60000, mvcc_skipped_rows:0, lm_filter_scanned_rows:0, lm_filter_skipped_rows:0, tot_rs_index_check:0ms, tot_read:0ms}} | keep order:false, stats:pseudo, annIndex:L2(vec..
  • 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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Jan 7, 2025
Copy link
Contributor

ti-chi-bot bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from breezewish, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 7, 2025
@breezewish breezewish changed the title [WIP] storage: Refine local index for more index kinds storage: Refine local index for more index kinds Jan 8, 2025
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

1 participant