From 647321af6f7bca91e499922aacb9c7f3eefc7732 Mon Sep 17 00:00:00 2001 From: Szymon Morek Date: Fri, 14 Oct 2022 12:28:13 +0000 Subject: [PATCH] Remove O(n) lookup in command container destructor Signed-off-by: Szymon Morek --- shared/source/command_container/cmdcontainer.cpp | 5 ++--- .../command_container/command_container_tests.cpp | 14 -------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index c6ce1804b5..168c0de696 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -254,9 +254,8 @@ void CommandContainer::handleCmdBufferAllocations(size_t startIndex) { if (isHandleFenceCompletionRequired) { this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]); } - if (!this->reusableAllocationList->peekContains(*cmdBufferAllocations[i])) { - reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]); - } + + reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]); } else { this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]); } diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index 180343e0b0..75cc60fa53 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -879,20 +879,6 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithoutA allocList.freeAllGraphicsAllocations(pDevice); } -TEST_F(CommandContainerTest, givenCmdContainerWhenDestroyCommandContainerThenAllocationListFilledCorrectly) { - auto cmdContainer = std::make_unique(); - AllocationsList allocList; - cmdContainer->initialize(pDevice, &allocList, false); - auto alloc = cmdContainer->getCmdBufferAllocations()[0]; - allocList.pushFrontOne(*alloc); - cmdContainer.reset(); - - EXPECT_TRUE(allocList.peekContains(*alloc)); - EXPECT_EQ(allocList.peekHead()->countThisAndAllConnected(), 1u); - - allocList.freeAllGraphicsAllocations(pDevice); -} - HWTEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithAllocationInListAndCsrTaskCountLowerThanAllocationThenReturnNullptr) { auto cmdContainer = std::make_unique(); auto &csr = pDevice->getUltCommandStreamReceiver();