From cb7108e336d53449ccf87a759f80f6520b4a0ca5 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Wed, 18 Aug 2021 17:51:43 -0700 Subject: [PATCH] Addresses comments around AZ_TRAIT_UNIT_TEST_NAME_COUNT from PR Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/Name/NameDictionary.cpp | 4 ++-- Code/Framework/AzCore/Tests/Name/NameTests.cpp | 12 ++++-------- .../AzTest/Platform/Android/AzTest_Traits_Android.h | 1 - .../AzTest/Platform/Linux/AzTest_Traits_Linux.h | 1 - .../AzTest/AzTest/Platform/Mac/AzTest_Traits_Mac.h | 1 - .../AzTest/Platform/Windows/AzTest_Traits_Windows.h | 1 - .../AzTest/AzTest/Platform/iOS/AzTest_Traits_iOS.h | 1 - 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Name/NameDictionary.cpp b/Code/Framework/AzCore/AzCore/Name/NameDictionary.cpp index 6f8672bb92..cf85e0f4e0 100644 --- a/Code/Framework/AzCore/AzCore/Name/NameDictionary.cpp +++ b/Code/Framework/AzCore/AzCore/Name/NameDictionary.cpp @@ -194,9 +194,9 @@ namespace AZ return; } - Internal::NameData* nameData = dictIt->second; // restore the pointer in case the intrusive ptr was already assigned by other thread + Internal::NameData* nameData = dictIt->second; - // Check m_hashCollision again inside the m_sharedMutex because a new collision could have happened + // Check m_hashCollision inside the m_sharedMutex because a new collision could have happened // on another thread before taking the lock. if (nameData->m_hashCollision) { diff --git a/Code/Framework/AzCore/Tests/Name/NameTests.cpp b/Code/Framework/AzCore/Tests/Name/NameTests.cpp index c0dc37715f..3db77ac4c4 100644 --- a/Code/Framework/AzCore/Tests/Name/NameTests.cpp +++ b/Code/Framework/AzCore/Tests/Name/NameTests.cpp @@ -604,9 +604,7 @@ namespace UnitTest AZ::NameDictionary::Create(); // 3 threads per name effectively makes two readers and one writer (the first to run will write in the dictionary) - // Using AZ_TRAIT_UNIT_TEST_NAME_COUNT / 2 since the following line generates 3000 threads and that triggers ASan failures, - // likely because of https://devblogs.microsoft.com/oldnewthing/20050729-14/?p=34773 - RunConcurrencyTest(AZ_TRAIT_UNIT_TEST_NAME_COUNT / 2, 3); + RunConcurrencyTest(AZStd::thread::hardware_concurrency(), 3); } TEST_F(NameTest, ConcurrencyDataTest_EachThreadCreatesOneName_HighCollisions) @@ -616,9 +614,7 @@ namespace UnitTest AZ::NameDictionary::Create(); // 3 threads per name effectively makes two readers and one writer (the first to run will write in the dictionary) - // Using AZ_TRAIT_UNIT_TEST_NAME_COUNT / 2 since the following line generates 3000 threads and that triggers ASan failures, - // likely because of https://devblogs.microsoft.com/oldnewthing/20050729-14/?p=34773 - RunConcurrencyTest(AZ_TRAIT_UNIT_TEST_NAME_COUNT / 2, 3); + RunConcurrencyTest(AZStd::thread::hardware_concurrency() / 2, 3); } TEST_F(NameTest, ConcurrencyDataTest_EachThreadRepeatedlyCreatesAndReleasesOneName_NoCollision) @@ -645,7 +641,7 @@ namespace UnitTest TEST_F(NameTest, DISABLED_NameVsStringPerf_Creation) { - constexpr int CreateCount = AZ_TRAIT_UNIT_TEST_NAME_COUNT; + constexpr int CreateCount = 1000; char buffer[RandomStringBufferSize]; @@ -654,7 +650,7 @@ namespace UnitTest AZStd::sys_time_t stringTime; { - const size_t dictionaryNoiseSize = AZ_TRAIT_UNIT_TEST_NAME_COUNT; + const size_t dictionaryNoiseSize = 1000; AZStd::vector existingNames; existingNames.reserve(dictionaryNoiseSize); diff --git a/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h b/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h index b210fb9b62..a8b4b3cc8c 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h +++ b/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h @@ -12,7 +12,6 @@ #define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5 #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_UNIT_TEST_NAME_COUNT 1000 #define AZ_TRAIT_TEST_APPEND_ROOT_FOLDER_TO_PATH true diff --git a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h index 8b8d87a5b9..d9b48b7835 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h +++ b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h @@ -12,7 +12,6 @@ #define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5 #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_UNIT_TEST_NAME_COUNT 1000 #define AZ_TRAIT_DISABLE_ALL_SAVE_DATA_TESTS true diff --git a/Code/Framework/AzTest/AzTest/Platform/Mac/AzTest_Traits_Mac.h b/Code/Framework/AzTest/AzTest/Platform/Mac/AzTest_Traits_Mac.h index a43c62ac98..69dd592a2b 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Mac/AzTest_Traits_Mac.h +++ b/Code/Framework/AzTest/AzTest/Platform/Mac/AzTest_Traits_Mac.h @@ -12,7 +12,6 @@ #define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5 #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_UNIT_TEST_NAME_COUNT 1000 #define AZ_TRAIT_DISABLE_ASSET_JOB_PARALLEL_TESTS true #define AZ_TRAIT_DISABLE_ASSET_MANAGER_FLOOD_TEST true diff --git a/Code/Framework/AzTest/AzTest/Platform/Windows/AzTest_Traits_Windows.h b/Code/Framework/AzTest/AzTest/Platform/Windows/AzTest_Traits_Windows.h index 3721d8891a..a11b8586f4 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Windows/AzTest_Traits_Windows.h +++ b/Code/Framework/AzTest/AzTest/Platform/Windows/AzTest_Traits_Windows.h @@ -13,4 +13,3 @@ #define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5 #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_UNIT_TEST_NAME_COUNT 1000 diff --git a/Code/Framework/AzTest/AzTest/Platform/iOS/AzTest_Traits_iOS.h b/Code/Framework/AzTest/AzTest/Platform/iOS/AzTest_Traits_iOS.h index a43c62ac98..69dd592a2b 100644 --- a/Code/Framework/AzTest/AzTest/Platform/iOS/AzTest_Traits_iOS.h +++ b/Code/Framework/AzTest/AzTest/Platform/iOS/AzTest_Traits_iOS.h @@ -12,7 +12,6 @@ #define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5 #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_UNIT_TEST_NAME_COUNT 1000 #define AZ_TRAIT_DISABLE_ASSET_JOB_PARALLEL_TESTS true #define AZ_TRAIT_DISABLE_ASSET_MANAGER_FLOOD_TEST true