Stop allocating the documents we return in RAM #4383
Labels
breaking change
The related changes are breaking for the users
bug
Something isn't working as expected
CPU/RAM usage
enhancement
New feature or improvement
performance
Related to the performance in term of search/indexation speed or RAM/CPU/Disk consumption
v2
Describe the bug
We allocate a lot of RAM to make search requests or document requests with a very high limit.
milli seems to handle that well, but in meilisearch, we then enter in the function that deserializes and allocates every document in RAM.
For a few thousand documents, that can easily take multiple MiB in RAM. And when people are running requests like that under a high load, it can get us OOM-killed. I think that's what is happening here (private link): https://github.com/meilisearch/meilisearch-support/issues/100
meilisearch/meilisearch/src/search.rs
Lines 592 to 644 in ff76d8f
meilisearch/meilisearch/src/routes/indexes/documents.rs
Lines 554 to 602 in ff76d8f
And as a bonus, it should make the search slightly faster when people are getting a lot of documents.
I’ve added the
spike
label because since we’re not returning the results in json-lines, I don’t know how it’ll work out with serde_json.We may need to do something very custom 😬
Expected behavior
We stream the requests to the end user without ever allocating more than one document at a time.
See https://docs.rs/actix-web/latest/actix_web/struct.HttpResponseBuilder.html#method.streaming
Meilisearch version:
all
Update after a first investigation
By limiting the maximum number of searches processed at the same time, we're limiting by a lot the RAM consumption.
Fixing this issue would make the engine faster (and able to process more search requests) but not especially avoid crashes.
The text was updated successfully, but these errors were encountered: