Modify rocksdb compilation

Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
pull/4973/head^2
XuanYang-cn 2021-01-14 15:12:08 +08:00 committed by yefu.chen
parent 4303fc0334
commit fb63983eb2
13 changed files with 68 additions and 53 deletions

1
.gitignore vendored
View File

@ -59,6 +59,7 @@ cmake_build/
.DS_Store
*.swp
cwrapper_build
**/cwrapper_rocksdb_build/
**/.clangd/*
**/compile_commands.json
**/.lint

View File

@ -57,14 +57,8 @@ lint:tools/bin/revive
@echo "Running $@ check"
@tools/bin/revive -formatter friendly -config tools/check/revive.toml ./...
get-rocksdb:
@go env -w CGO_CFLAGS="-I$(PWD)/internal/kv/rocksdb/cwrapper/output/include"
@go env -w CGO_LDFLAGS="-L$(PWD)/internal/kv/rocksdb/cwrapper/output/lib -l:librocksdb.a -lstdc++ -lm -lz"
@(env bash $(PWD)/internal/kv/rocksdb/cwrapper/build.sh)
@go get github.com/tecbot/gorocksdb
#TODO: Check code specifications by golangci-lint
static-check:get-rocksdb
static-check:
@echo "Running $@ check"
@GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=30m --config ./.golangci.yml ./internal/...
@ -85,7 +79,7 @@ endif
verifiers: getdeps cppcheck fmt static-check ruleguard
# Builds various components locally.
build-go: build-cpp get-rocksdb
build-go: build-cpp
@echo "Building each component's binary to './bin'"
@echo "Building master ..."
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="0" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/master $(PWD)/cmd/master/main.go 1>/dev/null
@ -105,6 +99,10 @@ build-go: build-cpp get-rocksdb
build-cpp:
@(env bash $(PWD)/scripts/core_build.sh -f "$(CUSTOM_THIRDPARTY_PATH)")
@(env bash $(PWD)/scripts/cwrapper_build.sh -t Release -f "$(CUSTOM_THIRDPARTY_PATH)")
@go env -w CGO_CFLAGS="-I$(PWD)/internal/kv/rocksdb/cwrapper/output/include"
@go env -w CGO_LDFLAGS="-L$(PWD)/internal/kv/rocksdb/cwrapper/output/lib -l:librocksdb.a -lstdc++ -lm -lz"
@(env bash $(PWD)/scripts/cwrapper_rocksdb_build.sh -t Release -f "$(CUSTOM_THIRDPARTY_PATH)")
@go get github.com/tecbot/gorocksdb
build-cpp-with-unittest:
@(env bash $(PWD)/scripts/core_build.sh -u -f "$(CUSTOM_THIRDPARTY_PATH)")
@ -114,7 +112,7 @@ build-cpp-with-unittest:
unittest: test-cpp test-go
#TODO: proxy master query node writer's unittest
test-go:get-rocksdb
test-go:build-cpp
@echo "Running go unittests..."
@(env bash $(PWD)/scripts/run_go_unittest.sh)

View File

@ -92,8 +92,8 @@ type IndexFilePathsResponse struct {
```go
type IndexNode interface {
Service
// SetTimeTickChannel(channelName string) error
// SetStatsChannel(channelName string) error
// SetTimeTickChannel(channelID string) error
// SetStatsChannel(channelID string) error
BuildIndex(req BuildIndexRequest) (BuildIndexResponse, error)
}

View File

@ -32,7 +32,7 @@ type CreateChannelRequest struct {
}
type CreateChannelResponse struct {
ChannelNames []string
ChannelIDs []string
}
```
@ -40,7 +40,7 @@ type CreateChannelResponse struct {
```go
type DestoryChannelRequest struct {
ChannelNames []string
ChannelIDs []string
}
```
@ -50,11 +50,11 @@ type DestoryChannelRequest struct {
```go
type DescribeChannelRequest struct {
ChannelNames []string
ChannelIDs []string
}
type ChannelDescription struct {
ChannelName string
ChannelID string
Owner OwnerDescription
}

View File

@ -70,8 +70,8 @@ type InvalidateCollMetaCacheRequest struct {
```go
type ProxyNode interface {
Service
//SetTimeTickChannel(channelName string) error
//SetStatsChannel(channelName string) error
//SetTimeTickChannel(channelID string) error
//SetStatsChannel(channelID string) error
CreateCollection(req CreateCollectionRequest) error
DropCollection(req DropCollectionRequest) error

View File

@ -359,8 +359,8 @@ Master
message TenantMeta {
uint64 id = 1;
uint64 num_query_nodes = 2;
repeated string insert_channel_names = 3;
string query_channel_name = 4;
repeated string insert_channel_ids = 3;
string query_channel_id = 4;
}
```
@ -370,7 +370,7 @@ message TenantMeta {
message ProxyMeta {
uint64 id = 1;
common.Address address = 2;
repeated string result_channel_names = 3;
repeated string result_channel_ids = 3;
}
```
@ -598,7 +598,7 @@ func NewSegmentManagement(ctx context.Context) *SegmentManagement
###### 10.7.1 Assign Segment ID to Inserted Rows
Master receives *AssignSegIDRequest* which contains a list of *SegIDRequest(count, channelName, collectionName, partitionName)* from Proxy. Segment Manager will assign the opened segments or open a new segment if there is no enough space, and Segment Manager will record the allocated space which can be reallocated after a expire duration.
Master receives *AssignSegIDRequest* which contains a list of *SegIDRequest(count, channelID, collectionName, partitionName)* from Proxy. Segment Manager will assign the opened segments or open a new segment if there is no enough space, and Segment Manager will record the allocated space which can be reallocated after a expire duration.
```go
func (segMgr *SegmentManager) AssignSegmentID(segIDReq []*internalpb.SegIDRequest) ([]*internalpb.SegIDAssignment, error)

View File

@ -161,8 +161,8 @@ type ReleasePartitionRequest struct {
```go
type CreateQueryChannelResponse struct {
RequestChannelName string
ResultChannelName string
RequestChannelID string
ResultChannelID string
}
```
@ -177,8 +177,8 @@ type QueryNode interface {
AddQueryChannel(req AddQueryChannelRequest) error
RemoveQueryChannel(req RemoveQueryChannelRequest) error
WatchDmChannels(req WatchDmChannelRequest) error
//SetTimeTickChannel(channelName string) error
//SetStatsChannel(channelName string) error
//SetTimeTickChannel(channelID string) error
//SetStatsChannel(channelID string) error
LoadSegments(req LoadSegmentRequest) error
ReleaseSegments(req ReleaseSegmentRequest) error
@ -193,8 +193,8 @@ type QueryNode interface {
```go
type AddQueryChannelRequest struct {
RequestBase
RequestChannelName string
ResultChannelName string
RequestChannelID string
ResultChannelID string
}
```
@ -202,8 +202,8 @@ type AddQueryChannelRequest struct {
```go
type RemoveQueryChannelRequest struct {
RequestChannelName string
ResultChannelName string
RequestChannelID string
ResultChannelID string
}
```
@ -211,7 +211,7 @@ type RemoveQueryChannelRequest struct {
```go
type WatchDmChannelRequest struct {
InsertChannelNames []string
InsertChannelIDs []string
}
```

View File

@ -6,7 +6,7 @@
#### 8.1 Overview
<img src="./figs/data_service.jpeg" width=700>
<img src="./figs/data_service.png" width=700>
#### 8.2 Data Service Interface
@ -58,7 +58,7 @@ type RegisterNodeResponse struct {
```go
type SegIDRequest struct {
Count uint32
ChannelName string
ChannelID string
CollectionID UniqueID
PartitionID UniqueID
}
@ -70,7 +70,7 @@ type AssignSegIDRequest struct {
type SegIDAssignment struct {
SegmentID UniqueID
ChannelName string
ChannelID string
Count uint32
CollectionID UniqueID
PartitionID UniqueID
@ -170,9 +170,9 @@ type DataNode interface {
Service
WatchDmChannels(req WatchDmChannelRequest) error
//WatchDdChannel(channelName string) error
//SetTimeTickChannel(channelName string) error
//SetStatsChannel(channelName string) error
//WatchDdChannel(channelID string) error
//SetTimeTickChannel(channelID string) error
//SetStatsChannel(channelID string) error
FlushSegments(req FlushSegRequest) error
}
@ -185,7 +185,7 @@ type DataNode interface {
```go
type WatchDmChannelRequest struct {
RequestBase
InsertChannelNames []string
InsertChannelIDs []string
}
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View File

@ -16,27 +16,35 @@ else()
endif()
message( STATUS "Thirdparty downloaded file path: ${THIRDPARTY_DOWNLOAD_PATH}" )
#-----------------------Using ccache if possible------------
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
message(STATUS "Using ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
set(ENV{CCACHE_COMMENTS} "1")
endif (CCACHE_FOUND)
macro( build_rocksdb )
message( STATUS "Building ROCKSDB-${ROCKSDB_VERSION} from source" )
set( ROCKSDB_CMAKE_ARGS
"-DWITH_GFLAGS=OFF"
"-DROCKSDB_BUILD_SHARED=OFF"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
#This is used to solve 'illegal instruction' problem in some machine
"-DPORTABLE=ON"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}"
)
)
ExternalProject_Add(
rocksdb-ep
PREFIX ${CMAKE_BINARY_DIR}/3rdparty_download/rocksdb-subbuild
BINARY_DIR rocksdb-bin
DOWNLOAD_DIR ${THIRDPARTY_DOWNLOAD_PATH}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
URL ${ROCKSDB_SOURCE_URL}
URL_MD5 "67f9e04fda62af551dd039c37b1808ac"
CMAKE_ARGS ${ROCKSDB_CMAKE_ARGS}
${EP_LOG_OPTIONS}
)
ExternalProject_Get_Property( rocksdb-ep INSTALL_DIR )
@ -49,5 +57,3 @@ macro( build_rocksdb )
endmacro()
build_rocksdb()
#endif()

30
scripts/cwrapper_rocksdb_build.sh Normal file → Executable file
View File

@ -9,26 +9,33 @@ done
DIR=$( cd -P $( dirname $SOURCE ) && pwd )
# echo $DIR
CMAKE_BUILD=${DIR}/../cwrapper_rocksdb_build
OUTPUT_LIB=${DIR}/../internal/kv/rocksdb/cwrapper/output
SRC_DIR=${DIR}/../internal/kv/rocksdb/cwrapper
CGO_CFLAGS="-I$(SRC_DIR)/output/include"
CGO_LDFLAGS="-L$(SRC_DIR)/output/lib -l:librocksdb.a -lstdc++ -lm -lz"
OUTPUT_LIB=${SRC_DIR}/output
if [ -d ${OUTPUT_LIB} ];then
rm -rf ${OUTPUT_LIB}
if [ ! -d ${CMAKE_BUILD} ];then
mkdir ${CMAKE_BUILD}
fi
if [ ! -d ${OUTPUT_LIB} ];then
mkdir ${OUTPUT_LIB}
fi
mkdir ${OUTPUT_LIB}
BUILD_TYPE="Debug"
CUSTOM_THIRDPARTY_PATH=""
while getopts "t:h:" arg; do
while getopts "t:h:f:" arg; do
case $arg in
f)
CUSTOM_THIRDPARTY_PATH=$OPTARG
;;
t)
BUILD_TYPE=$OPTARG # BUILD_TYPE
;;
h) # help
echo "-t: build type(default: Debug)
-f: custom thirdparty path(default: "")
-h: help
"
exit 0
@ -40,10 +47,13 @@ while getopts "t:h:" arg; do
esac
done
echo "BUILD_TYPE: " $BUILD_TYPE
echo "CUSTOM_THIRDPARTY_PATH: " $CUSTOM_THIRDPARTY_PATH
pushd ${OUTPUT_LIB}
pushd ${CMAKE_BUILD}
CMAKE_CMD="cmake \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${SRC_DIR}"
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${OUTPUT_LIB} \
-DCUSTOM_THIRDPARTY_DOWNLOAD_PATH=${CUSTOM_THIRDPARTY_PATH} ${SRC_DIR}"
${CMAKE_CMD}
echo ${CMAKE_CMD}