From: khizmax Date: Sun, 21 May 2017 16:54:23 +0000 (+0300) Subject: Added SPSC queue stress tests X-Git-Tag: v2.3.0~25 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2883a81206f2ed696b66730ea426761f9a6ac4a4;p=libcds.git Added SPSC queue stress tests --- diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index 3fa22f27..06367d47 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -451,6 +451,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-queue-bounded", "str {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-spsc-queue", "stress-spsc-queue.vcxproj", "{CDC54B7B-B882-4CC8-87A2-E237D0D945B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1289,6 +1291,18 @@ Global {A73D9B24-8ADA-4FE6-8ABE-C02335E780DC}.Release|Win32.Build.0 = Release|Win32 {A73D9B24-8ADA-4FE6-8ABE-C02335E780DC}.Release|x64.ActiveCfg = Release|x64 {A73D9B24-8ADA-4FE6-8ABE-C02335E780DC}.Release|x64.Build.0 = Release|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|Win32.Build.0 = Debug|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|x64.ActiveCfg = Debug|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|x64.Build.0 = Debug|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|Win32.ActiveCfg = Release|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|Win32.Build.0 = Release|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|x64.ActiveCfg = Release|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1375,6 +1389,7 @@ Global {6E1A2CC4-E36F-4C93-9C01-CC36DE0CAB89} = {EECB80F9-47E4-451E-A94E-7EC86B484F0A} {5E92F39A-0B39-49C2-B7F1-2D87E51E07BF} = {EECB80F9-47E4-451E-A94E-7EC86B484F0A} {A73D9B24-8ADA-4FE6-8ABE-C02335E780DC} = {EECB80F9-47E4-451E-A94E-7EC86B484F0A} + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2} = {EECB80F9-47E4-451E-A94E-7EC86B484F0A} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc14/stress-spsc-queue.vcxproj b/projects/Win/vc14/stress-spsc-queue.vcxproj new file mode 100644 index 00000000..7d3644f7 --- /dev/null +++ b/projects/Win/vc14/stress-spsc-queue.vcxproj @@ -0,0 +1,244 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2} + Win32Proj + stress_spsc_queue + 8.1 + stress-spsc-queue + + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/projects/Win/vc141/cds.sln b/projects/Win/vc141/cds.sln index 081f2fdb..cb9297c8 100644 --- a/projects/Win/vc141/cds.sln +++ b/projects/Win/vc141/cds.sln @@ -452,6 +452,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-queue-push", "stress {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress-spsc-queue", "stress-spsc-queue.vcxproj", "{CDC54B7B-B882-4CC8-87A2-E237D0D945B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1290,6 +1292,18 @@ Global {47B9F1F9-C9F1-4F25-842B-EE8E6447FE50}.Release|Win32.Build.0 = Release|Win32 {47B9F1F9-C9F1-4F25-842B-EE8E6447FE50}.Release|x64.ActiveCfg = Release|x64 {47B9F1F9-C9F1-4F25-842B-EE8E6447FE50}.Release|x64.Build.0 = Release|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|Win32.Build.0 = Debug|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|x64.ActiveCfg = Debug|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Debug|x64.Build.0 = Debug|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|Win32.ActiveCfg = Release|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|Win32.Build.0 = Release|Win32 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|x64.ActiveCfg = Release|x64 + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1376,6 +1390,7 @@ Global {E845EB69-9335-4A03-93D0-6D6AC48462E5} = {7DDE0A26-F02B-44FE-9206-552E39BC4A55} {EACBF8EC-C58F-4CC8-9435-21BE9812287A} = {7DDE0A26-F02B-44FE-9206-552E39BC4A55} {47B9F1F9-C9F1-4F25-842B-EE8E6447FE50} = {7DDE0A26-F02B-44FE-9206-552E39BC4A55} + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2} = {7DDE0A26-F02B-44FE-9206-552E39BC4A55} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc141/stress-spsc-queue.vcxproj b/projects/Win/vc141/stress-spsc-queue.vcxproj new file mode 100644 index 00000000..6b7c8318 --- /dev/null +++ b/projects/Win/vc141/stress-spsc-queue.vcxproj @@ -0,0 +1,244 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + {CDC54B7B-B882-4CC8-87A2-E237D0D945B2} + Win32Proj + stress_spsc_queue + 8.1 + stress-spsc-queue + + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + DebugFastLink + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;stress-framework_d.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + _ENABLE_ATOMIC_ALIGNMENT_FIX;CDS_ENABLE_HPSTAT;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(SolutionDir)..\..\..\test\stress;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;stress-framework.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/test/stress/data/test-debug.conf b/test/stress/data/test-debug.conf index 2ff2ada4..8e5378e4 100644 --- a/test/stress/data/test-debug.conf +++ b/test/stress/data/test-debug.conf @@ -100,6 +100,14 @@ ThreadCount=4 QueueSize=1024 PassCount=100000 +[spsc_queue] +QueueSize=1024 +PassCount=500 + +[spsc_buffer] +BufferSize=100000 +PushCount=100000 + [pqueue_pop] ThreadCount=4 QueueSize=30000 diff --git a/test/stress/data/test-express-x86.conf b/test/stress/data/test-express-x86.conf index 6c6ff5ce..aed3e4f4 100644 --- a/test/stress/data/test-express-x86.conf +++ b/test/stress/data/test-express-x86.conf @@ -99,6 +99,14 @@ ThreadCount=4 QueueSize=1024 PassCount=100000 +[spsc_queue] +QueueSize=1024 +PassCount=400 + +[spsc_buffer] +BufferSize=100000 +PushCount=200000 + [pqueue_pop] ThreadCount=4 QueueSize=500000 diff --git a/test/stress/data/test-express.conf b/test/stress/data/test-express.conf index 05dc3677..4316df80 100644 --- a/test/stress/data/test-express.conf +++ b/test/stress/data/test-express.conf @@ -98,6 +98,14 @@ ThreadCount=4 QueueSize=1024 PassCount=100000 +[spsc_queue] +QueueSize=1024 +PassCount=500 + +[spsc_buffer] +BufferSize=100000 +PushCount=300000 + [pqueue_pop] ThreadCount=8 QueueSize=500000 diff --git a/test/stress/data/test.conf b/test/stress/data/test.conf index 1cf4ca8a..0cba9666 100644 --- a/test/stress/data/test.conf +++ b/test/stress/data/test.conf @@ -100,6 +100,14 @@ ThreadCount=8 QueueSize=1024 PassCount=1000000 +[spsc_queue] +QueueSize=1024 +PassCount=1024 + +[spsc_buffer] +BufferSize=1000000 +PushCount=1000000 + [pqueue_pop] ThreadCount=8 QueueSize=2000000 diff --git a/test/stress/queue/CMakeLists.txt b/test/stress/queue/CMakeLists.txt index 8bee83ad..729f97c3 100644 --- a/test/stress/queue/CMakeLists.txt +++ b/test/stress/queue/CMakeLists.txt @@ -53,6 +53,17 @@ add_executable(${CDSSTRESS_QUEUE_BOUNDED} ${CDSSTRESS_QUEUE_BOUNDED_SOURCES} $) +target_link_libraries(${CDSSTRESS_SPSC_QUEUE} ${CDS_TEST_LIBRARIES}) +add_test(NAME ${CDSSTRESS_SPSC_QUEUE} COMMAND ${CDSSTRESS_SPSC_QUEUE} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + # stress-queue add_custom_target( stress-queue @@ -62,4 +73,5 @@ add_custom_target( stress-queue ${CDSSTRESS_QUEUE_PUSHPOP} ${CDSSTRESS_QUEUE_RANDOM} ${CDSSTRESS_QUEUE_BOUNDED} + ${CDSSTRESS_SPSC_QUEUE} ) \ No newline at end of file diff --git a/test/stress/queue/queue_type.h b/test/stress/queue/queue_type.h index 2e02f218..c2077083 100644 --- a/test/stress/queue/queue_type.h +++ b/test/stress/queue/queue_type.h @@ -293,6 +293,51 @@ namespace fc_details{ } }; + // singlre-consumer version + struct traits_VyukovMPSCCycleQueue_dyn: public traits_VyukovMPMCCycleQueue_dyn + { + static const bool single_consumer = true; + }; + class VyukovMPSCCycleQueue_dyn + : public cds::container::VyukovMPMCCycleQueue< Value, traits_VyukovMPSCCycleQueue_dyn > + { + typedef cds::container::VyukovMPMCCycleQueue< Value, traits_VyukovMPSCCycleQueue_dyn > base_class; + public: + VyukovMPSCCycleQueue_dyn() + : base_class( 1024 * 64 ) + {} + VyukovMPSCCycleQueue_dyn( size_t nCapacity ) + : base_class( nCapacity ) + {} + + cds::opt::none statistics() const + { + return cds::opt::none(); + } + }; + + struct traits_VyukovMPSCCycleQueue_dyn_ic: public traits_VyukovMPMCCycleQueue_dyn + { + static const bool single_consumer = true; + }; + class VyukovMPSCCycleQueue_dyn_ic + : public cds::container::VyukovMPMCCycleQueue< Value, traits_VyukovMPSCCycleQueue_dyn_ic > + { + typedef cds::container::VyukovMPMCCycleQueue< Value, traits_VyukovMPSCCycleQueue_dyn_ic > base_class; + public: + VyukovMPSCCycleQueue_dyn_ic() + : base_class( 1024 * 64 ) + {} + VyukovMPSCCycleQueue_dyn_ic( size_t nCapacity ) + : base_class( nCapacity ) + {} + + cds::opt::none statistics() const + { + return cds::opt::none(); + } + }; + // WeakRingBuffer struct traits_WeakRingBuffer_dyn: public cds::container::weak_ringbuffer::traits @@ -317,6 +362,24 @@ namespace fc_details{ } }; + class WeakRingBuffer_void_dyn + : public cds::container::WeakRingBuffer< void, traits_WeakRingBuffer_dyn > + { + typedef cds::container::WeakRingBuffer< void, traits_WeakRingBuffer_dyn > base_class; + public: + WeakRingBuffer_void_dyn() + : base_class( 1024 * 64 ) + {} + WeakRingBuffer_void_dyn( size_t nCapacity ) + : base_class( nCapacity ) + {} + + cds::opt::none statistics() const + { + return cds::opt::none(); + } + }; + // BasketQueue typedef cds::container::BasketQueue< cds::gc::HP , Value > BasketQueue_HP; @@ -814,9 +877,16 @@ namespace cds_test { CDSSTRESS_Queue_F( test_fixture, VyukovMPMCCycleQueue_dyn ) \ CDSSTRESS_Queue_F( test_fixture, VyukovMPMCCycleQueue_dyn_ic ) +#define CDSSTRESS_VyukovSingleConsumerQueue( test_fixture ) \ + CDSSTRESS_Queue_F( test_fixture, VyukovMPSCCycleQueue_dyn ) \ + CDSSTRESS_Queue_F( test_fixture, VyukovMPSCCycleQueue_dyn_ic ) + #define CDSSTRESS_WeakRingBuffer( test_fixture ) \ CDSSTRESS_Queue_F( test_fixture, WeakRingBuffer_dyn ) +#define CDSSTRESS_WeakRingBuffer_void( test_fixture ) \ + CDSSTRESS_Queue_F( test_fixture, WeakRingBuffer_void_dyn ) + #define CDSSTRESS_StdQueue( test_fixture ) \ CDSSTRESS_Queue_F( test_fixture, StdQueue_deque_Spinlock ) \ CDSSTRESS_Queue_F( test_fixture, StdQueue_list_Spinlock ) \ diff --git a/test/stress/queue/spsc_buffer.cpp b/test/stress/queue/spsc_buffer.cpp new file mode 100644 index 00000000..32ca2d55 --- /dev/null +++ b/test/stress/queue/spsc_buffer.cpp @@ -0,0 +1,230 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "queue_type.h" + +#include +#include +#include + +// Single producer/single consumer buffer push/pop test +namespace { + + static size_t s_nBufferSize = 1024*1024; + static size_t s_nPushCount = 1000000; + + static std::atomic s_nProducerDone( 0 ); + + class spsc_buffer: public cds_test::stress_fixture + { + protected: + typedef size_t value_type; + + enum { + producer_thread, + consumer_thread + }; + + template + class Producer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Producer( cds_test::thread_pool& pool, Queue& queue ) + : base_class( pool, producer_thread ) + , m_Queue( queue ) + {} + + Producer( Producer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Producer( *this ); + } + + virtual void test() + { + size_t const nPushCount = s_nPushCount; + + for ( size_t i = 0; i < nPushCount; ++i ) { + size_t len = rand( 1024 ) + 64; + void* buf = m_Queue.back( len ); + if ( buf ) { + memset( buf, len % 256, len ); + m_Queue.push_back(); + m_nPushed += len; + } + else + ++m_nPushFailed; + } + + s_nProducerDone.fetch_add( 1 ); + } + + public: + Queue& m_Queue; + size_t m_nPushFailed = 0; + size_t m_nPushed = 0; + }; + + template + class Consumer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Queue& m_Queue; + size_t m_nPopEmpty = 0; + size_t m_nPopped = 0; + size_t m_nBadValue = 0; + size_t m_nPopFrontFailed = 0; + + public: + Consumer( cds_test::thread_pool& pool, Queue& queue ) + : base_class( pool, consumer_thread ) + , m_Queue( queue ) + {} + Consumer( Consumer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Consumer( *this ); + } + + virtual void test() + { + while ( true ) { + auto buf = m_Queue.front(); + if ( buf.first ) { + m_nPopped += buf.second; + + uint8_t val = static_cast( buf.second % 256 ); + uint8_t const* p = reinterpret_cast( buf.first ); + for ( uint8_t const* pEnd = p + buf.second; p < pEnd; ++p ) { + if ( *p != val ) { + ++m_nBadValue; + break; + } + } + + if ( !m_Queue.pop_front() ) + ++m_nPopFrontFailed; + } + else { + ++m_nPopEmpty; + if ( s_nProducerDone.load() != 0 ) { + if ( m_Queue.empty() ) + break; + } + } + } + } + }; + + protected: + size_t m_nThreadPushCount; + + protected: + template + void test_queue( Queue& q ) + { + cds_test::thread_pool& pool = get_pool(); + auto producer = new Producer( pool, q ); + auto consumer = new Consumer( pool, q ); + + pool.add( producer, 1 ); + pool.add( consumer, 1 ); + + s_nProducerDone.store( 0 ); + + propout() << std::make_pair( "buffer_size", s_nBufferSize ) + << std::make_pair( "push_count", s_nPushCount ); + + std::chrono::milliseconds duration = pool.run(); + + propout() << std::make_pair( "duration", duration ); + + // analyze result + EXPECT_EQ( consumer->m_nBadValue, 0u ); + EXPECT_EQ( consumer->m_nPopFrontFailed, 0u ); + EXPECT_EQ( consumer->m_nPopped, producer->m_nPushed ); + + propout() + << std::make_pair( "producer_push_length", producer->m_nPushed ) + << std::make_pair( "producer_push_failed", producer->m_nPushFailed ) + << std::make_pair( "consumer_pop_length", consumer->m_nPopped ) + << std::make_pair( "consumer_pop_empty", consumer->m_nPopEmpty ) + << std::make_pair( "consumer_bad_value", consumer->m_nBadValue ) + << std::make_pair( "consumer_pop_front_failed", consumer->m_nPopFrontFailed ); + } + + template + void test( Queue& q ) + { + test_queue( q ); + propout() << q.statistics(); + } + + public: + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "spsc_buffer" ); + + s_nBufferSize = cfg.get_size_t( "BufferSize", s_nBufferSize ); + s_nPushCount = cfg.get_size_t( "PushCount", s_nPushCount ); + + if ( s_nBufferSize < 1024 * 64 ) + s_nBufferSize = 1024 * 64; + if ( s_nPushCount == 0u ) + s_nPushCount = 1024; + } + }; + +#undef CDSSTRESS_Queue_F +#define CDSSTRESS_Queue_F( test_fixture, type_name ) \ + TEST_F( test_fixture, type_name ) \ + { \ + typedef queue::Types< value_type >::type_name queue_type; \ + queue_type queue( s_nBufferSize ); \ + test( queue ); \ + } + + CDSSTRESS_WeakRingBuffer_void( spsc_buffer ) + +#undef CDSSTRESS_Queue_F + +} // namespace diff --git a/test/stress/queue/spsc_queue.cpp b/test/stress/queue/spsc_queue.cpp new file mode 100644 index 00000000..3a0119dd --- /dev/null +++ b/test/stress/queue/spsc_queue.cpp @@ -0,0 +1,227 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "queue_type.h" + +#include +#include +#include + +// Single producer/single consumer queue push/pop test +namespace { + + static size_t s_nQueueSize = 1024; + static size_t s_nPassCount = 1024; + + static std::atomic s_nProducerDone( 0 ); + + class spsc_queue: public cds_test::stress_fixture + { + protected: + typedef size_t value_type; + + enum { + producer_thread, + consumer_thread + }; + + template + class Producer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Producer( cds_test::thread_pool& pool, Queue& queue ) + : base_class( pool, producer_thread ) + , m_Queue( queue ) + {} + + Producer( Producer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Producer( *this ); + } + + virtual void test() + { + size_t const nPushCount = s_nQueueSize * s_nPassCount; + m_nPushFailed = 0; + + for ( value_type v = 0; v < nPushCount; ++v ) { + if ( !m_Queue.push( v ) ) { + ++m_nPushFailed; + --v; + } + } + + s_nProducerDone.fetch_add( 1 ); + } + + public: + Queue& m_Queue; + size_t m_nPushFailed = 0; + }; + + template + class Consumer: public cds_test::thread + { + typedef cds_test::thread base_class; + + public: + Queue& m_Queue; + size_t m_nPopEmpty = 0; + size_t m_nPopped = 0; + size_t m_nBadValue = 0; + + public: + Consumer( cds_test::thread_pool& pool, Queue& queue ) + : base_class( pool, consumer_thread ) + , m_Queue( queue ) + {} + Consumer( Consumer& src ) + : base_class( src ) + , m_Queue( src.m_Queue ) + {} + + virtual thread * clone() + { + return new Consumer( *this ); + } + + virtual void test() + { + value_type v; + value_type prev = 0 - 1; + + while ( true ) { + if ( m_Queue.pop( v )) { + ++m_nPopped; + if ( v != prev + 1 ) + ++m_nBadValue; + prev = v; + } + else { + ++m_nPopEmpty; + + if ( s_nProducerDone.load() != 0 ) { + if ( m_Queue.empty()) + break; + } + } + } + } + }; + + protected: + size_t m_nThreadPushCount; + + protected: + template + void test_queue( Queue& q ) + { + cds_test::thread_pool& pool = get_pool(); + auto producer = new Producer( pool, q ); + auto consumer = new Consumer( pool, q ); + + pool.add( producer, 1 ); + pool.add( consumer, 1 ); + + s_nProducerDone.store( 0 ); + + propout() << std::make_pair( "queue_size", s_nQueueSize ) + << std::make_pair( "pass_count", s_nPassCount ); + + std::chrono::milliseconds duration = pool.run(); + + propout() << std::make_pair( "duration", duration ); + + // analyze result + EXPECT_EQ( consumer->m_nBadValue, 0u ); + EXPECT_EQ( consumer->m_nPopped, s_nQueueSize * s_nPassCount ); + + propout() + << std::make_pair( "producer_push_count", s_nQueueSize * s_nPassCount ) + << std::make_pair( "producer_push_failed", producer->m_nPushFailed ) + << std::make_pair( "consumer_pop_count", consumer->m_nPopped ) + << std::make_pair( "consumer_pop_empty", consumer->m_nPopEmpty ) + << std::make_pair( "consumer_bad_value", consumer->m_nBadValue ); + } + + template + void test( Queue& q ) + { + test_queue( q ); + propout() << q.statistics(); + } + + public: + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "spsc_queue" ); + + s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize ); + s_nPassCount = cfg.get_size_t( "PassCount", s_nPassCount ); + + if ( s_nQueueSize == 0u ) + s_nQueueSize = 1024; + if ( s_nPassCount == 0u ) + s_nPassCount = 1024; + } + }; + + //CDSSTRESS_MSQueue( spsc_queue ) + //CDSSTRESS_MoirQueue( spsc_queue ) + //CDSSTRESS_BasketQueue( spsc_queue ) + //CDSSTRESS_OptimsticQueue( spsc_queue ) + //CDSSTRESS_FCQueue( spsc_queue ) + //CDSSTRESS_FCDeque( spsc_queue ) + //CDSSTRESS_RWQueue( spsc_queue ) + //CDSSTRESS_StdQueue( spsc_queue ) + +#undef CDSSTRESS_Queue_F +#define CDSSTRESS_Queue_F( test_fixture, type_name ) \ + TEST_F( test_fixture, type_name ) \ + { \ + typedef queue::Types< value_type >::type_name queue_type; \ + queue_type queue( s_nQueueSize ); \ + test( queue ); \ + } + + CDSSTRESS_WeakRingBuffer( spsc_queue ) + CDSSTRESS_VyukovQueue( spsc_queue ) + CDSSTRESS_VyukovSingleConsumerQueue( spsc_queue ) + +#undef CDSSTRESS_Queue_F + +} // namespace