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

Merged
merged 11 commits into from
Jan 20, 2025

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). The envolution could be discovered by format_version field.
  • 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 again

# 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}}

Disaggregated mode: (WIP)

# Using tiup aa448adf
# Start a cluster
~/tiup/bin/tiup-playground nightly --tag vector_test --mode=tidb-disagg

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

# Verify there is delta layer local index:
$ python3 main.py local test
+-----------------+--------------------+----------------+-------------------+
|   StableIndexed |   StableNotIndexed |   DeltaIndexed |   DeltaNotIndexed |
|-----------------+--------------------+----------------+-------------------|
|           60000 |                  0 |          60000 |                 0 |
+-----------------+--------------------+----------------+-------------------+

Explain analyze:
tiflash_task:{time:26.6ms, loops:1, threads:72}, tiflash_wait: {pipeline_queue_wait: 1ms}, vector_idx:{load:{total:0ms,from_s3:0,from_disk:0,from_cache:1},search:{total:0ms,visited_nodes:186,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:0, delta_bytes:0, segments:1, stale_read_regions:0, tot_build_snapshot:0ms, tot_build_bitmap:10ms, tot_build_inputstream:10ms, min_local_stream:21ms, max_local_stream:22ms, 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:1ms, disagg_cache_hit_bytes: 110286531, disagg_cache_miss_bytes: 0}}

# Restart the cluster using binary from this PR
~/tiup/bin/tiup-playground nightly --tag vector_test --mode=tidb-disagg --tiflash.binpath ~/tiflash/cmake-build-Release/artifacts/tiflash

# Verify again
$ python3 main.py local test
+-----------------+--------------------+----------------+-------------------+
|   StableIndexed |   StableNotIndexed |   DeltaIndexed |   DeltaNotIndexed |
|-----------------+--------------------+----------------+-------------------|
|           60000 |                  0 |          60000 |                 0 |
+-----------------+--------------------+----------------+-------------------+
Explain analyze:
tiflash_task:{time:22.3ms, loops:1, threads:72}, tiflash_wait: {pipeline_queue_wait: 1ms}, vector_idx:{load:{total:0ms,from_s3:0,from_disk:0,from_cache:1},search:{total:0ms,visited_nodes:186,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:0, delta_bytes:0, segments:1, stale_read_regions:0, tot_build_snapshot:0ms, tot_build_bitmap:7ms, tot_build_inputstream:7ms, min_local_stream:16ms, max_local_stream:17ms, 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:1ms, disagg_cache_hit_bytes: 110286531, disagg_cache_miss_bytes: 0}}
  • 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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels 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
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 20, 2025
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

Copy link
Contributor

ti-chi-bot bot commented Jan 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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,Lloyd-Pottiger]

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 Jan 20, 2025
Copy link
Contributor

ti-chi-bot bot commented Jan 20, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-20 04:25:54.219172648 +0000 UTC m=+68481.550092051: ☑️ agreed by Lloyd-Pottiger.
  • 2025-01-20 09:52:02.402454381 +0000 UTC m=+88049.733374010: ☑️ agreed by JaySon-Huang.

Copy link
Contributor

ti-chi-bot bot commented Jan 20, 2025

@breezewish: 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.

@breezewish
Copy link
Member Author

/retest

@breezewish
Copy link
Member Author

/merge

@ti-chi-bot ti-chi-bot bot merged commit a381c31 into pingcap:master Jan 20, 2025
5 checks passed
@breezewish breezewish deleted the wenxuan/fts_refine/2 branch January 21, 2025 00:47
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.

3 participants