mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
fix: flag to limit usm reuse based on memory usage
Host usm and device usm for igfx checks system memory usage. Device usm for dgfx checks local memory usage. If used memory is above limit threshold: - no new allocations will be saved for reuse - cleaner will use shorter hold time of 2 seconds - cleaner will free all eligible allocations, regardless of async deleter thread having work Motivation: in case of gfx memory being full, making resident new allocations will require evictions which leads to massive slowdown on enqueue calls. This change aims to minimize cases where extra memory usage from usm reuse mechanism leads to above situation. Related-To: NEO-6893, NEO-14160 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5684eb0dca
commit
915d657420
@@ -12,6 +12,7 @@
|
||||
#include "shared/source/memory_manager/alignment_selector.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/memadvise_flags.h"
|
||||
#include "shared/source/memory_manager/unified_memory_reuse.h"
|
||||
#include "shared/source/os_interface/os_memory.h"
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
|
||||
@@ -338,26 +339,11 @@ class MemoryManager {
|
||||
|
||||
virtual void getExtraDeviceProperties(uint32_t rootDeviceIndex, uint32_t *moduleId, uint16_t *serverType) { return; }
|
||||
|
||||
std::unique_lock<std::mutex> obtainHostAllocationsReuseLock() const {
|
||||
return std::unique_lock<std::mutex>(hostAllocationsReuseMtx);
|
||||
}
|
||||
void initUsmReuseLimits();
|
||||
UsmReuseInfo usmReuseInfo;
|
||||
|
||||
void initUsmReuseMaxSize();
|
||||
|
||||
uint64_t getMaxAllocationsSavedForReuseSize() const {
|
||||
return maxAllocationsSavedForReuseSize;
|
||||
}
|
||||
|
||||
void recordHostAllocationSaveForReuse(uint64_t size) {
|
||||
hostAllocationsSavedForReuseSize += size;
|
||||
}
|
||||
|
||||
void recordHostAllocationGetFromReuse(uint64_t size) {
|
||||
hostAllocationsSavedForReuseSize -= size;
|
||||
}
|
||||
|
||||
uint64_t getHostAllocationsSavedForReuseSize() const {
|
||||
return hostAllocationsSavedForReuseSize;
|
||||
bool shouldLimitAllocationsReuse() const {
|
||||
return getUsedSystemMemorySize() >= usmReuseInfo.getLimitAllocationsReuseThreshold();
|
||||
}
|
||||
|
||||
void addCustomHeapAllocatorConfig(AllocationType allocationType, bool isFrontWindowPool, const CustomHeapAllocatorConfig &config);
|
||||
@@ -436,9 +422,6 @@ class MemoryManager {
|
||||
std::mutex physicalMemoryAllocationMapMutex;
|
||||
std::unique_ptr<std::atomic<size_t>[]> localMemAllocsSize;
|
||||
std::atomic<size_t> sysMemAllocsSize;
|
||||
uint64_t maxAllocationsSavedForReuseSize = 0u;
|
||||
uint64_t hostAllocationsSavedForReuseSize = 0u;
|
||||
mutable std::mutex hostAllocationsReuseMtx;
|
||||
std::map<std::pair<AllocationType, bool>, CustomHeapAllocatorConfig> customHeapAllocators;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user