From 4b04f93ad0161bef8434300a153aed4f5ec100f9 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 28 Apr 2025 13:58:20 -0400 Subject: Misc shared cache performance improvements --- view/sharedcache/core/SharedCacheController.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'view/sharedcache/core/SharedCacheController.cpp') diff --git a/view/sharedcache/core/SharedCacheController.cpp b/view/sharedcache/core/SharedCacheController.cpp index 41118d7a..ff688f3c 100644 --- a/view/sharedcache/core/SharedCacheController.cpp +++ b/view/sharedcache/core/SharedCacheController.cpp @@ -160,7 +160,10 @@ bool SharedCacheController::ApplyRegion(BinaryView& view, const CacheRegion& reg // TODO: We can use the AddRemoteMemoryRegion if we want to reload on view init. // TODO: ^ The above is only useful if we assume that all files will be available across database loads. // TODO: we might allow a user to select non-persisted memory regions as an option. - view.GetMemoryMap()->AddDataMemoryRegion(memoryRegionName, region.start, buffer, region.flags); + bool addedMemoryRegion = view.GetMemoryMap()->AddDataMemoryRegion(memoryRegionName, region.start, buffer, region.flags); + if (!addedMemoryRegion) + return false; + // TODO: We might want to make this auto if we decide to "reload" all loaded region in view init. // If we are not associated with an image we can create a section here to set the semantics. // This is important for stub regions, as they will deref non image data that we want to retrieve the value of. @@ -195,10 +198,12 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image { // Load all regions of an image and mark the image as loaded. // NOTE: The regions lock m_loadMutex themselves, so we do not hold it up here. + view.BeginBulkAddSegments(); bool loadedRegion = false; for (const auto& regionStart : image.regionStarts) if (ApplyRegionAtAddress(view, regionStart)) loadedRegion = true; + view.EndBulkAddSegments(); // The ApplyRegionAtAddress no longer holds the lock, we can take it now. std::unique_lock lock(m_loadMutex); -- cgit v1.3.1