Skip to content

Commit

Permalink
introduce folly to use concurrent hash map further
Browse files Browse the repository at this point in the history
Signed-off-by: lizhen <[email protected]>
  • Loading branch information
tedli committed Oct 30, 2023
1 parent 9f59020 commit f148fa4
Show file tree
Hide file tree
Showing 18 changed files with 485 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ deps

tests/tmp
bin

compile_commands.json
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ENDIF ()

IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(CMAKE_CXX_FLAGS "-pthread")
SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ -lc++ -lc++abi ${CMAKE_EXE_LINKER_FLAGS}")
ADD_DEFINITIONS(-DOS_MACOSX)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand Down Expand Up @@ -103,8 +104,9 @@ include(cmake/findTools.cmake)
include(cmake/leveldb.cmake)
include(cmake/libevent.cmake)
include(cmake/llhttp.cmake)
include(cmake/spdlog.cmake)
include(cmake/fmt.cmake)
include(cmake/spdlog.cmake)
include(cmake/folly.cmake)


ADD_SUBDIRECTORY(src/pstd)
Expand Down
15 changes: 15 additions & 0 deletions cmake/boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

include(cmake/utils.cmake)

FetchContent_DeclareGitHubWithMirror(pikiwidb-boost
pikiwidb/boost boost-1.83.0
SHA256=A3B453E3D5FD39E6A4C733C31548512A1E74B7328D4C358FAC562930A0E6E5B4
)

FetchContent_MakeAvailableWithArgs(pikiwidb-boost)
15 changes: 15 additions & 0 deletions cmake/double-conversion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

include(cmake/utils.cmake)

FetchContent_DeclareGitHubWithMirror(double-conversion
google/double-conversion v3.3.0
SHA256=4080014235f90854ffade6d1c423940b314bbca273a338235f049da296e47183
)

FetchContent_MakeAvailableWithArgs(double-conversion)
19 changes: 13 additions & 6 deletions cmake/fmt.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# fmt
FETCHCONTENT_DECLARE(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.1.0
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

include(cmake/utils.cmake)

FetchContent_DeclareGitHubWithMirror(fmt
fmtlib/fmt 10.1.1
SHA256=3c2e73019178ad72b0614a3124f25de454b9ca3a1afe81d5447b8d3cbdb6d322
)
FETCHCONTENT_MAKEAVAILABLE(fmt)

FetchContent_MakeAvailableWithArgs(fmt)
40 changes: 40 additions & 0 deletions cmake/folly.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

set(DEPS_FETCH_PROXY "" CACHE STRING
"a template URL to proxy the traffic for fetching dependencies, e.g. with DEPS_FETCH_PROXY = https://some-proxy/,
https://example/some-dep.zip -> https://some-proxy/https://example/some-dep.zip")

cmake_host_system_information(RESULT CPU_CORE QUERY NUMBER_OF_LOGICAL_CORES)

if(CMAKE_GENERATOR STREQUAL "Ninja")
set(MAKE_COMMAND make -j${CPU_CORE})
else()
set(MAKE_COMMAND $(MAKE) -j${CPU_CORE})
endif()

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

include(cmake/utils.cmake)
include(cmake/boost.cmake)
include(cmake/unwind.cmake)
include(cmake/gflags.cmake)
include(cmake/glog.cmake)
include(cmake/double-conversion.cmake)
include(cmake/fmt.cmake)

add_compile_definitions(FOLLY_NO_CONFIG)

FetchContent_DeclareGitHubWithMirror(pikiwidb-folly
pikiwidb/folly v2023.10.16.00
SHA256=EB29DC13474E3979A0680F624FF5820FA7A4E9CE0110607669AE87D69CFC104D
)

FetchContent_MakeAvailableWithArgs(pikiwidb-folly)

target_link_libraries(pikiwidb-folly pikiwidb-boost glog double-conversion fmt)
target_include_directories(pikiwidb-folly PUBLIC $<BUILD_INTERFACE:${pikiwidb-folly_SOURCE_DIR}>)
25 changes: 25 additions & 0 deletions cmake/gflags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

include(cmake/utils.cmake)

FetchContent_DeclareGitHubWithMirror(gflags
gflags/gflags v2.2.2
SHA256=19713a36c9f32b33df59d1c79b4958434cb005b5b47dc5400a7a4b078111d9b5
)

FetchContent_MakeAvailableWithArgs(gflags
GFLAGS_NAMESPACE=gflags
BUILD_STATIC_LIBS=ON
BUILD_SHARED_LIBS=OFF
BUILD_gflags_LIB=ON
BUILD_gflags_nothreads_LIB=OFF
)

find_package(Threads REQUIRED)

target_link_libraries(gflags_static Threads::Threads)
22 changes: 22 additions & 0 deletions cmake/glog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

include(cmake/utils.cmake)

FetchContent_Declare(glog
URL https://github.com/google/glog/archive/v0.6.0.zip
URL_HASH SHA256=122fb6b712808ef43fbf80f75c52a21c9760683dae470154f02bddfc61135022
PATCH_COMMAND patch -p1 -s -E -i ${PROJECT_SOURCE_DIR}/cmake/patches/glog_demangle.patch
)

FetchContent_MakeAvailableWithArgs(glog
CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/modules/glog
WITH_GFLAGS=ON
WITH_GTEST=OFF
BUILD_SHARED_LIBS=OFF
WITH_UNWIND=ON
)
11 changes: 11 additions & 0 deletions cmake/modules/glog/FindUnwind.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

if(unwind_SOURCE_DIR)
message(STATUS "Found unwind in ${unwind_SOURCE_DIR}")

add_library(unwind::unwind ALIAS unwind)
install(TARGETS unwind EXPORT glog-targets)
endif()
10 changes: 10 additions & 0 deletions cmake/modules/glog/Findgflags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

if(gflags_SOURCE_DIR)
message(STATUS "Found gflags in ${gflags_SOURCE_DIR}")

install(TARGETS gflags_static EXPORT glog-targets)
endif()
10 changes: 10 additions & 0 deletions cmake/modules/spdlog/fmtConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023-present, Qihoo, Inc. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

if(fmt_SOURCE_DIR)
message(STATUS "Found fmt in ${fmt_SOURCE_DIR}")

add_library(fmt::fmt ALIAS fmt)
endif()
Loading

0 comments on commit f148fa4

Please sign in to comment.