Add greedy mempool with configuration options #433
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds a usable memory limit to each query. If
P_QUERY_MEMORY_LIMIT
is set then it will use that as a fixed limit for greedy memory pool otherwise it will use 80% of available memory as hard limit for this query. In effect if the memory pool quota is filled it then datafusion will try to spill few execution nodes in temporary directory.Note -
This solution is not dynamic as Datafusion does not keep track of actual available memory during its runtime. Pool size set to Datafusion is a fixed number in bytes.
So it can happen that bound was set higher but some other process took memory and thus actual allocation cannot happen at runtime, Datafusion will return an error in that case instead of OOM.
Vice versa if bound was set lower and later during runtime if more memory is available for use even then it won't be able to use it
Alternative:
We can keep this option to set limit but when it is not set then we just use the default Unbounded memory manager
This PR has: