Browse Source

Update libsniper version to v1.2.0 (#5685)

* Update libsniper version

* fix libsniper readme
Oleg Romanenko 5 years ago
parent
commit
ce4a602a84

+ 1 - 1
frameworks/C++/libsniper/README.md

@@ -1,4 +1,4 @@
-# [libsniper](https://gitlab.com/rtbtech/libs/libsniper) (C++) Benchmarking Test
+# [libsniper](https://github.com/rtbtech/libsniper) (C++) Benchmarking Test
 
 
 ## Description
 ## Description
 
 

+ 4 - 2
frameworks/C++/libsniper/libsniper.dockerfile

@@ -27,9 +27,11 @@ WORKDIR /libsniper_bench
 
 
 RUN git config --global http.sslverify false
 RUN git config --global http.sslverify false
 
 
-RUN git clone https://gitlab.com/rtbtech/libs/libsniper.git libs/core
+ENV LIBSNIPER_VER v1.2.0
 
 
-RUN cd libs/core && git checkout 75f5cee4dcdc604d74703f5255e6f4cca20f50ce
+RUN git clone https://github.com/rtbtech/libsniper.git libs/core
+
+RUN cd libs/core && git checkout v1.2.0
 
 
 RUN mkdir build && cd /libsniper_bench/build && cmake -DCMAKE_BUILD_TYPE=Release -S .. && make --jobs=`nproc`
 RUN mkdir build && cd /libsniper_bench/build && cmake -DCMAKE_BUILD_TYPE=Release -S .. && make --jobs=`nproc`
 
 

+ 3 - 0
frameworks/C++/libsniper/libsniper_bench/CMakeLists.txt

@@ -23,6 +23,9 @@ set(Boost_USE_MULTITHREADED ON)
 find_package(Boost REQUIRED)
 find_package(Boost REQUIRED)
 find_package(Threads REQUIRED)
 find_package(Threads REQUIRED)
 find_package(fmt REQUIRED)
 find_package(fmt REQUIRED)
+find_package(TCMalloc REQUIRED)
+find_package(Libev REQUIRED)
+find_package(Libre2 REQUIRED)
 
 
 include_directories(SYSTEM ${BOOST_INCLUDE_DIRS})
 include_directories(SYSTEM ${BOOST_INCLUDE_DIRS})
 
 

+ 22 - 0
frameworks/C++/libsniper/libsniper_bench/cmake/FindLibev.cmake

@@ -0,0 +1,22 @@
+FIND_PATH(LIBEV_INCLUDE_DIR ev.h /usr/local/include /opt/local/include /usr/include)
+FIND_LIBRARY(LIBEV_LIBRARY NAMES libev.a PATH /usr/local/lib /opt/local/lib /usr/lib)
+
+IF (LIBEV_INCLUDE_DIR AND LIBEV_LIBRARY)
+    SET(LIBEV_FOUND TRUE)
+ENDIF ()
+
+IF (LIBEV_FOUND)
+    IF (NOT Libev_FIND_QUIETLY)
+        MESSAGE(STATUS "Found libev: ${LIBEV_LIBRARY}")
+    ENDIF ()
+ELSE()
+    IF (Libev_FIND_REQUIRED)
+        IF(NOT LIBEV_INCLUDE_DIR)
+            MESSAGE(FATAL_ERROR "Could not find libev header file!")
+        ENDIF()
+
+        IF(NOT LIBEV_LIBRARY)
+            MESSAGE(FATAL_ERROR "Could not find libev library file!")
+        ENDIF()
+    ENDIF ()
+ENDIF ()

+ 22 - 0
frameworks/C++/libsniper/libsniper_bench/cmake/FindLibre2.cmake

@@ -0,0 +1,22 @@
+FIND_PATH(LIBRE2_INCLUDE_DIR re2/re2.h /usr/local/include /opt/local/include /usr/include)
+FIND_LIBRARY(LIBRE2_LIBRARY NAMES libre2.a PATH /usr/local/lib /opt/local/lib /usr/lib)
+
+IF (LIBRE2_INCLUDE_DIR AND LIBRE2_LIBRARY)
+    SET(LIBRE2_FOUND TRUE)
+ENDIF ()
+
+IF (LIBRE2_FOUND)
+    IF (NOT Libre2_FIND_QUIETLY)
+        MESSAGE(STATUS "Found libre2: ${LIBRE2_LIBRARY}")
+    ENDIF ()
+ELSE()
+    IF (Libre2_FIND_REQUIRED)
+        IF(NOT LIBRE2_INCLUDE_DIR)
+            MESSAGE(FATAL_ERROR "Could not find libre2 header file!")
+        ENDIF()
+
+        IF(NOT LIBRE2_LIBRARY)
+            MESSAGE(FATAL_ERROR "Could not find libre2 library file!")
+        ENDIF()
+    ENDIF ()
+ENDIF ()

+ 22 - 0
frameworks/C++/libsniper/libsniper_bench/cmake/FindTCMalloc.cmake

@@ -0,0 +1,22 @@
+FIND_PATH(LIBTCMALLOC_INCLUDE_DIR gperftools/malloc_extension.h /usr/local/include /opt/local/include /usr/include)
+FIND_LIBRARY(LIBTCMALLOC_LIBRARY NAMES libtcmalloc${CMAKE_SHARED_LIBRARY_SUFFIX} PATH /usr/local/lib /opt/local/lib /usr/lib)
+
+IF (LIBTCMALLOC_INCLUDE_DIR AND LIBTCMALLOC_LIBRARY)
+    SET(LIBTCMALLOC_FOUND TRUE)
+ENDIF ()
+
+IF (LIBTCMALLOC_FOUND)
+    IF (NOT TCMalloc_FIND_QUIETLY)
+        MESSAGE(STATUS "Found libtcmalloc: ${LIBTCMALLOC_LIBRARY}")
+    ENDIF ()
+ELSE()
+    IF (TCMalloc_FIND_REQUIRED)
+        IF(NOT LIBTCMALLOC_INCLUDE_DIR)
+            MESSAGE(FATAL_ERROR "Could not find libtcmalloc header file!")
+        ENDIF()
+
+        IF(NOT LIBTCMALLOC_LIBRARY)
+            MESSAGE(FATAL_ERROR "Could not find libtcmalloc library file!")
+        ENDIF()
+    ENDIF ()
+ENDIF ()

+ 1 - 1
frameworks/C++/libsniper/libsniper_bench/cmake/flags.cmake

@@ -1,5 +1,5 @@
 set(COMMON_FLAGS "\
 set(COMMON_FLAGS "\
-    -march=corei7-avx \
+    -march=native \
     -pipe \
     -pipe \
     -m64 \
     -m64 \
     -msse \
     -msse \

+ 2 - 0
frameworks/C++/libsniper/libsniper_bench/src/CMakeLists.txt

@@ -4,6 +4,8 @@ include_directories(${SNIPER_INCLUDE_DIRS})
 set(PROJECT_LIBS
 set(PROJECT_LIBS
         ${CMAKE_THREAD_LIBS_INIT}
         ${CMAKE_THREAD_LIBS_INIT}
         ${BOOST_LIBRARIES}
         ${BOOST_LIBRARIES}
+        dl ${LIBRE2_LIBRARY}
+        ${LIBEV_LIBRARY}
         backtrace dl
         backtrace dl
         fmt::fmt
         fmt::fmt
         stdc++fs.a
         stdc++fs.a

+ 7 - 16
frameworks/C++/libsniper/libsniper_bench/src/main.cpp

@@ -43,29 +43,22 @@ private:
         }
         }
     }
     }
 
 
-    static string gen_date()
-    {
-        return fmt::format("Date: {:%a, %d %b %Y %H:%M:%S} GMT\r\n", fmt::gmtime(time(nullptr)));
-    }
-
     void worker(unsigned thread_num)
     void worker(unsigned thread_num)
     {
     {
         auto loop = event::make_loop();
         auto loop = event::make_loop();
         check(loop, "[Server] cannot init event loop");
         check(loop, "[Server] cannot init event loop");
 
 
-        http::server::Config config;
-        config.max_conns = 100000;
-        config.connection.keep_alive_timeout = 10min;
-        config.connection.request_read_timeout = 10s;
+        auto config = http::server::make_config();
+        config->add_server_header = true;
+        config->add_date_header = true;
+        config->max_conns = 100000;
+        config->keep_alive_timeout = 0ms;
+        config->buffer_size = 128 * 1024;
 
 
         http::Server http_server(loop, config);
         http::Server http_server(loop, config);
         check(http_server.bind("", 8090), "[Server] cannot bind to localhost:8090");
         check(http_server.bind("", 8090), "[Server] cannot bind to localhost:8090");
 
 
-        string date = gen_date();
-        http_server.set_cb_request([&, this](const auto& conn, const auto& req, const auto& resp) {
-            resp->add_header_nocopy("Server: libsniper\r\n");
-            resp->add_header_copy(date);
-
+        http_server.set_cb([&, this](const auto& conn, const auto& req, const auto& resp) {
             if (req->path() == "/plaintext") {
             if (req->path() == "/plaintext") {
                 resp->code = http::ResponseStatus::OK;
                 resp->code = http::ResponseStatus::OK;
                 resp->add_header_nocopy("Content-Type: text/plain; charset=UTF-8\r\n");
                 resp->add_header_nocopy("Content-Type: text/plain; charset=UTF-8\r\n");
@@ -83,8 +76,6 @@ private:
                 loop->break_loop(ev::ALL);
                 loop->break_loop(ev::ALL);
         });
         });
 
 
-        event::TimerRepeat timer_update_time(loop, 1s, [&date] { date = gen_date(); });
-
         loop->run();
         loop->run();
     }
     }