forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure memory reservation before shrinking cache and allocating (face…
…bookincubator#9136) Summary: Currently, the following allocation APIs in memory allocator, namely allocateNonContiguous, allocateContiguous and growContiguous attempt to shrink data cache (if enough allocated memory is not available) before attempting to increase reservation from caller's respective memory pool and finally doing the actual allocation. Motivation: The cache shrinking process used during allocation attempts is currently lock-free and opportunistic. This means that a memory chunk cleared by one thread can be seized by another thread attempting to allocate. We aim to implement a mechanism that will serialize the release and capture of this chunk for a single thread if multiple previous attempts have been unsuccessful. This will make the process more deterministic for a single thread. However, the current implementation presents a challenge. If a thread holds a lock inside the cache and then attempts a reservation, the reservation can trigger an arbitration. If the arbitration selects a query to terminate but one of its drivers is waiting on the cache lock, it will never go off thread, resulting in a deadlock. To avoid this, we propose attempting reservation before trying to shrink the cache, thereby keeping their locking mechanisms independent. Also, if the reservation fails, it can lead to unnecessary clearing of cached memory. Reviewed By: xiaoxmeng Differential Revision: D55034349
- Loading branch information
1 parent
8f0adb1
commit 9a51d53
Showing
6 changed files
with
181 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.