mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
Merge #776
776: Reduce incremental indexing time of `words_prefix_position_docids` DB r=curquiza a=loiclec Fixes partially https://github.com/meilisearch/milli/issues/605 The `words_prefix_position_docids` can easily contain millions of entries. Thus, iterating over it can be very expensive. But we do so needlessly for every document addition tasks. It can sometimes cause indexing performance issues when : - a user sends many `documentAdditionOrUpdate` tasks that cannot be all batched together (for example if they are interspersed with `documentDeletion` tasks) - the documents contain long, diverse text fields, thus increasing the number of entries in `words_prefix_position_docids` - the index has accumulated many soft-deleted documents, further increasing the size of `words_prefix_position_docids` - the machine running Meilisearch does not have great IO performance (e.g. slow SSD, or quota-limited by the cloud provider) Note, before approving the PR: the only changed file should be `milli/src/update/words_prefix_position_docids.rs`. Co-authored-by: Loïc Lecrenier <loic.lecrenier@me.com>
This commit is contained in:
commit
758b4acea7
@ -140,6 +140,10 @@ impl<'t, 'u, 'i> WordPrefixPositionDocids<'t, 'u, 'i> {
|
|||||||
|
|
||||||
// We remove all the entries that are no more required in this word prefix position
|
// We remove all the entries that are no more required in this word prefix position
|
||||||
// docids database.
|
// docids database.
|
||||||
|
// We also avoid iterating over the whole `word_prefix_position_docids` database if we know in
|
||||||
|
// advance that the `if del_prefix_fst_words.contains(prefix.as_bytes()) {` condition below
|
||||||
|
// will always be false (i.e. if `del_prefix_fst_words` is empty).
|
||||||
|
if !del_prefix_fst_words.is_empty() {
|
||||||
let mut iter =
|
let mut iter =
|
||||||
self.index.word_prefix_position_docids.iter_mut(self.wtxn)?.lazily_decode_data();
|
self.index.word_prefix_position_docids.iter_mut(self.wtxn)?.lazily_decode_data();
|
||||||
while let Some(((prefix, _), _)) = iter.next().transpose()? {
|
while let Some(((prefix, _), _)) = iter.next().transpose()? {
|
||||||
@ -147,8 +151,8 @@ impl<'t, 'u, 'i> WordPrefixPositionDocids<'t, 'u, 'i> {
|
|||||||
unsafe { iter.del_current()? };
|
unsafe { iter.del_current()? };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(iter);
|
drop(iter);
|
||||||
|
}
|
||||||
|
|
||||||
// We finally write all the word prefix position docids into the LMDB database.
|
// We finally write all the word prefix position docids into the LMDB database.
|
||||||
sorter_into_lmdb_database(
|
sorter_into_lmdb_database(
|
||||||
|
Loading…
Reference in New Issue
Block a user