FalkorDB / FalkorDB

A super fast Graph Database uses GraphBLAS under the hood for its sparse adjacency matrix graph representation. Our goal is to provide the best Knowledge Graph for LLM (GraphRAG).
https://www.falkordb.com/
Other
717 stars 29 forks source link

Limit memory allocation when running a query #245

Open gkorland opened 1 year ago

gkorland commented 1 year ago

Created by: @AviAvni Source: https://github.com/RedisGraph/RedisGraph/issues/2129 Arena allocator can be used to limit the amount of memory used while running queries

Brief design

each thread in the thread pool will have arena allocator instance each arena allocator will have X amount of memory declared in the config memory needed for running the query will be allocated from the arena allocator reset the arena allocator after the query run is finished

Pros

Cons

Open questions

gkorland commented 1 year ago

Origin comment by: @LiorKogan Suppose you have 32 threads. I think it is not acceptable for each thread to get 1/32 of the total RAM quota. There should probably be 'large memory' and 'small memory' threads.

I'm not sure if there is some way to estimate (or categorize) a query according to its size (do we need statistics for this?), and channel it to the most suitable thread.

Maybe simpler: to allow a single thread to allocate from 2 or more allocators when a small number of queries are actually running concurrently.

gkorland commented 1 year ago

Origin comment by: @LiorKogan I'll try to phrase the problem:

Naïve solution:

Problems with the Naïve solution:

Suggested solution: