Browse Source

Better C++ coroutine lifetime in actors KIKIMR-18962

snaury 1 year ago
parent
commit
e8f301ee51

+ 2 - 0
library/cpp/actors/cppcoro/CMakeLists.darwin-x86_64.txt

@@ -6,6 +6,7 @@
 # original buildsystem will not be accepted.
 
 
+add_subdirectory(benchmark)
 add_subdirectory(ut)
 
 add_library(cpp-actors-cppcoro)
@@ -18,5 +19,6 @@ target_sources(cpp-actors-cppcoro PRIVATE
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/await_callback.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_actor.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_group.cpp
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_result.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task.cpp
 )

+ 2 - 0
library/cpp/actors/cppcoro/CMakeLists.linux-aarch64.txt

@@ -6,6 +6,7 @@
 # original buildsystem will not be accepted.
 
 
+add_subdirectory(benchmark)
 add_subdirectory(ut)
 
 add_library(cpp-actors-cppcoro)
@@ -19,5 +20,6 @@ target_sources(cpp-actors-cppcoro PRIVATE
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/await_callback.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_actor.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_group.cpp
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_result.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task.cpp
 )

+ 2 - 0
library/cpp/actors/cppcoro/CMakeLists.linux-x86_64.txt

@@ -6,6 +6,7 @@
 # original buildsystem will not be accepted.
 
 
+add_subdirectory(benchmark)
 add_subdirectory(ut)
 
 add_library(cpp-actors-cppcoro)
@@ -19,5 +20,6 @@ target_sources(cpp-actors-cppcoro PRIVATE
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/await_callback.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_actor.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_group.cpp
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_result.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task.cpp
 )

+ 2 - 0
library/cpp/actors/cppcoro/CMakeLists.windows-x86_64.txt

@@ -6,6 +6,7 @@
 # original buildsystem will not be accepted.
 
 
+add_subdirectory(benchmark)
 add_subdirectory(ut)
 
 add_library(cpp-actors-cppcoro)
@@ -18,5 +19,6 @@ target_sources(cpp-actors-cppcoro PRIVATE
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/await_callback.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_actor.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_group.cpp
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task_result.cpp
   ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/task.cpp
 )

+ 9 - 7
library/cpp/actors/cppcoro/await_callback.h

@@ -5,6 +5,7 @@
 namespace NActors {
 
     namespace NDetail {
+
         template<class TAwaitable>
         decltype(auto) GetAwaiter(TAwaitable&& awaitable) {
             if constexpr (requires { ((TAwaitable&&) awaitable).operator co_await(); }) {
@@ -23,31 +24,31 @@ namespace NActors {
         class TCallbackResult {
         public:
             TCallbackResult(TCallback& callback)
-                : Callback_(callback)
+                : Callback(callback)
             {}
 
             template<class TRealResult>
             void return_value(TRealResult&& result) noexcept {
-                Callback_(std::forward<TRealResult>(result));
+                Callback(std::forward<TRealResult>(result));
             }
 
         private:
-            TCallback& Callback_;
+            TCallback& Callback;
         };
 
         template<class TCallback>
         class TCallbackResult<TCallback, void> {
         public:
             TCallbackResult(TCallback& callback)
-                : Callback_(callback)
+                : Callback(callback)
             {}
 
             void return_void() noexcept {
-                Callback_();
+                Callback();
             }
 
         private:
-            TCallback& Callback_;
+            TCallback& Callback;
         };
 
         template<class TAwaitable, class TCallback>
@@ -82,7 +83,8 @@ namespace NActors {
 
             TAwaitThenCallback(THandle) noexcept {}
         };
-    }
+
+    } // namespace NDetail
 
     /**
      * Awaits the awaitable and calls callback with the result.

+ 31 - 0
library/cpp/actors/cppcoro/benchmark/CMakeLists.darwin-x86_64.txt

@@ -0,0 +1,31 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+  contrib-libs-cxxsupp
+  yutil
+  library-cpp-cpuid_check
+  testing-benchmark-main
+  cpp-actors-cppcoro
+)
+target_link_options(benchmark PRIVATE
+  -Wl,-platform_version,macos,11.0,11.0
+  -fPIC
+  -fPIC
+  -framework
+  CoreFoundation
+)
+target_sources(benchmark PRIVATE
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/benchmark/main.cpp
+)
+target_allocator(benchmark
+  system_allocator
+)
+vcs_info(benchmark)

+ 34 - 0
library/cpp/actors/cppcoro/benchmark/CMakeLists.linux-aarch64.txt

@@ -0,0 +1,34 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+  contrib-libs-linux-headers
+  contrib-libs-cxxsupp
+  yutil
+  testing-benchmark-main
+  cpp-actors-cppcoro
+)
+target_link_options(benchmark PRIVATE
+  -ldl
+  -lrt
+  -Wl,--no-as-needed
+  -fPIC
+  -fPIC
+  -lpthread
+  -lrt
+  -ldl
+)
+target_sources(benchmark PRIVATE
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/benchmark/main.cpp
+)
+target_allocator(benchmark
+  cpp-malloc-jemalloc
+)
+vcs_info(benchmark)

+ 36 - 0
library/cpp/actors/cppcoro/benchmark/CMakeLists.linux-x86_64.txt

@@ -0,0 +1,36 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+  contrib-libs-linux-headers
+  contrib-libs-cxxsupp
+  yutil
+  library-cpp-cpuid_check
+  testing-benchmark-main
+  cpp-actors-cppcoro
+)
+target_link_options(benchmark PRIVATE
+  -ldl
+  -lrt
+  -Wl,--no-as-needed
+  -fPIC
+  -fPIC
+  -lpthread
+  -lrt
+  -ldl
+)
+target_sources(benchmark PRIVATE
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/benchmark/main.cpp
+)
+target_allocator(benchmark
+  cpp-malloc-tcmalloc
+  libs-tcmalloc-no_percpu_cache
+)
+vcs_info(benchmark)

+ 17 - 0
library/cpp/actors/cppcoro/benchmark/CMakeLists.txt

@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+  include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+  include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+  include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+  include(CMakeLists.linux-x86_64.txt)
+endif()

+ 24 - 0
library/cpp/actors/cppcoro/benchmark/CMakeLists.windows-x86_64.txt

@@ -0,0 +1,24 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+  contrib-libs-cxxsupp
+  yutil
+  library-cpp-cpuid_check
+  testing-benchmark-main
+  cpp-actors-cppcoro
+)
+target_sources(benchmark PRIVATE
+  ${CMAKE_SOURCE_DIR}/library/cpp/actors/cppcoro/benchmark/main.cpp
+)
+target_allocator(benchmark
+  system_allocator
+)
+vcs_info(benchmark)

Some files were not shown because too many files changed in this diff