-
Notifications
You must be signed in to change notification settings - Fork 183
DiskBBQ Updates #4037
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
base: main
Are you sure you want to change the base?
DiskBBQ Updates #4037
Changes from 4 commits
7bedece
4583290
862a91d
51a3d9b
a4bbee5
494cff4
c1f575f
932e654
4d48690
f7bfc84
63848b0
0f439c9
ac1f1c7
74c05cc
a48779d
223ab9b
bccb811
cc7facd
ac19151
13ed394
bec850a
cb58619
11fed20
f5718a8
d749699
a79adb2
9ea1f2c
ffb69e4
535040e
eb0def0
115bd30
f688cb0
68eb0c0
a4920a6
7eae37f
366ecf4
18c1c5a
fc63931
d3072e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,7 +46,13 @@ | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## Ensure data nodes have enough memory [_ensure_data_nodes_have_enough_memory] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {{es}} uses the [HNSW](https://arxiv.org/abs/1603.09320) algorithm for approximate kNN search. HNSW is a graph-based algorithm which only works efficiently when most vector data is held in memory. You should ensure that data nodes have at least enough RAM to hold the vector data and index structures. To check the size of the vector data, you can use the [Analyze index disk usage](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-disk-usage) API. | ||||||||||||||||||||||||||
| {{es}} uses either the [HNSW](https://arxiv.org/abs/1603.09320) algorithm or the [DiskBBQ](https://www.elastic.co/search-labs/blog/diskbbq-elasticsearch-introduction) algorithm for approximate kNN search. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| HNSW is a graph-based algorithm which only works efficiently when most vector data is held in memory. You should ensure that data nodes have at least enough RAM to hold the vector data and index structures. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| DiskBBQ is a clustering algorithm which can scale effeciently often on less memory than HNSW. Where HNSW will typically experience poor performance without sufficient memory to fit the entire structure in RAM instead DiskBBQ will scale linearly when using less available memory than the total index size. You can start with enough RAM to hold the vector data and index structures but it's likely you will be able to use less than this and still maintain good performance. In testing we find this will be between 1-5% of the index structure size (centroids and quantized vector data) per unique query where unique queries access non-overlapping clusters. | ||||||||||||||||||||||||||
|
Check notice on line 53 in deploy-manage/production-guidance/optimize-performance/approximate-knn-search.md
|
||||||||||||||||||||||||||
john-wagster marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| To check the size of the vector data, you can use the [Analyze index disk usage](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-disk-usage) API. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Here are estimates for different element types and quantization levels: | ||||||||||||||||||||||||||
john-wagster marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -59,6 +65,8 @@ | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| If utilizing HNSW, the graph must also be in memory, to estimate the required bytes use `num_vectors * 4 * HNSW.m`. The default value for `HNSW.m` is 16, so by default `num_vectors * 4 * 16`. | ||||||||||||||||||||||||||
john-wagster marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| If utilizing DiskBBQ, a fraction of the clusters and centroids will need to be in memory. When doing this estimation it makes more sense to include both the index structure and the quantized vectors together as the structures are dependent. To estimate the total bytes we compute the cost of the centroids as `num_clusters * num_dimensions * 4 + num_clusters * (num_dimensions + 14)` plus the cost of the quantized vectors within the clusters as `num_vectors * ((num_dimensions/8 + 14 + 2) * 2)` where `num_clusters` is defined as `num_vectors / vectors_per_cluster` which by default will be `num_vectors / 384` | ||||||||||||||||||||||||||
|
Check notice on line 68 in deploy-manage/production-guidance/optimize-performance/approximate-knn-search.md
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| If utilizing DiskBBQ, a fraction of the clusters and centroids will need to be in memory. When doing this estimation it makes more sense to include both the index structure and the quantized vectors together as the structures are dependent. To estimate the total bytes we compute the cost of the centroids as `num_clusters * num_dimensions * 4 + num_clusters * (num_dimensions + 14)` plus the cost of the quantized vectors within the clusters as `num_vectors * ((num_dimensions/8 + 14 + 2) * 2)` where `num_clusters` is defined as `num_vectors / vectors_per_cluster` which by default will be `num_vectors / 384` | |
| ### DiskBBQ only: RAM for clusters and centroids in memory | |
| If you're using DiskBBQ, a fraction of the clusters and centroids need to be in memory. When doing this estimation, it makes more sense to include both the index structure and the quantized vectors together, as the structures are dependent. To estimate the total bytes, compute the following: | |
| * The cost of the centroids: `num_clusters * num_dimensions * 4 + num_clusters * (num_dimensions + 14)` | |
| * The cost of the quantized vectors within the clusters: `num_vectors * ((num_dimensions/8 + 14 + 2) * 2)` | |
| Then add them together: `centroids`+`quantized_vectors` | |
| `num_clusters` is defined as `num_vectors / vectors_per_cluster`, which by default will be `num_vectors / 384`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by math related FYI, you can now do LaTeX in our docs: https://elastic.github.io/docs-builder/syntax/math/
Might be overkill for arithmetic but just sharing for info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good comment is good; when I get a min I'll clean up with Latex both calcs and see if making them more readable in that sense helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made an attempt to make this easier to read; let me know what ya'll think.
Uh oh!
There was an error while loading. Please reload this page.