Skip to content

Storages: Optimize vector search in scenarios with updates (#9597)#9609

Merged
ti-chi-bot[bot] merged 8 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-9597-to-release-8.5
Nov 14, 2024
Merged

Storages: Optimize vector search in scenarios with updates (#9597)#9609
ti-chi-bot[bot] merged 8 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-9597-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #9597

What problem does this PR solve?

Issue Number: ref #9600 , close #9599

Problem Summary:

What is changed and how it works?

Before, the read path of vector search is:

  1. load stable vector index.
  2. read all packs that contain TopK results.
  3. load all ColumnFileTiny vector index.
  4. read all ColumnFileTiny that contain TopK results.
  5. read Memtable.

A simple example:

We have cf_0 (indexed, offset: 100-110), cf_1 (indexed, offset: 110-120), cf_3 (indexed, offset: 120-130), cf_4 (memtable, offset: 130-140), dmfile_0 (indexed, offset: 0-100, each 10 rows as a pack), to find top5:

  1. load stable vector index: top5 is [0, 10, 13, 25, 99]
  2. read all packs that contain TopK results: read pack_0, pack_1, pack_2, pack_9
  3. load all ColumnFileTiny vector index: top5 is [100, 101, 115, 116, 119]
  4. read all ColumnFileTiny that contain TopK results: read cf_0, cf_1
  5. read Memtable: read cf_4.

So, in this example, we need to read 3 packs and 3 ColumnFileTinys.

This PR changes the read path to:

  1. load stable vector index and all ColumnFileTiny vector index.
  2. read all packs that contain TopK results.
  3. read all ColumnFileTiny that contain TopK results.
  4. read Memtable.

Still using the above example, now to find top5:

  1. load stable vector index and all ColumnFileTiny vector index: top5 is [0, 10, 13, 100, 101]
  2. read all packs that contain TopK results: read pack_0, pack_1
  3. read all ColumnFileTiny that contain TopK results: read cf_0
  4. read Memtable: read cf_4

Now, we only need to read 2 packs and 2 ColumnFileTinys.

Benchmark

Run VectorDBBench, about 750k stable, 250k delta with vector index, 4k delta without vector index.

Note: should disable compact tiflash replica

diff --git a/vectordb_bench/backend/clients/tidb_serverless/tidb.py b/vectordb_bench/backend/clients/tidb_serverless/tidb.py
index b927568..fe9d5e3 100644
--- a/vectordb_bench/backend/clients/tidb_serverless/tidb.py
+++ b/vectordb_bench/backend/clients/tidb_serverless/tidb.py
@@ -104,9 +104,9 @@ class TiDBServeless(VectorDB):
             else:
                 break
 
-        log.info("Begin compact tiflash replica")
-        self._compact_tiflash()
-        log.info("Successful compacted tiflash replica")
+        # log.info("Begin compact tiflash replica")
+        # self._compact_tiflash()
+        # log.info("Successful compacted tiflash replica")
 
         log_reduce_seq = 0
         while True:

Without this PR (after fix #9599)

"metrics": {
    "max_load_count": 0,
    "load_duration": 747.9345,
    "qps": 71.4146,
    "serial_latency_p99": 0.1081,
    "recall": 0.9327
}

With this PR

"metrics": {
    "max_load_count": 0,
    "load_duration": 778.9001,
    "qps": 125.046,
    "serial_latency_p99": 0.0851,
    "recall": 0.931
}

All data are in stable

"metrics": {
    "max_load_count": 0,
    "load_duration": 0.0,
    "qps": 205.3793,
    "serial_latency_p99": 0.0282,
    "recall": 0.9016
}
Improve 75% the performance of vector search in scenarios with updates.

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

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

fix

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

fix

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Nov 13, 2024
@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Nov 13, 2024
@Lloyd-Pottiger
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 13, 2024
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@Lloyd-Pottiger
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 14, 2024
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 14, 2024
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Nov 14, 2024

[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

Details 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 Nov 14, 2024
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Nov 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-14 05:07:08.738374643 +0000 UTC m=+505590.929243635: ☑️ agreed by Lloyd-Pottiger.
  • 2024-11-14 07:22:01.94607242 +0000 UTC m=+513684.136941417: ☑️ agreed by JaySon-Huang.

@JaySon-Huang
Copy link
Contributor

/test pull-integration-test

@ti-chi-bot ti-chi-bot bot merged commit 932059d into pingcap:release-8.5 Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants