Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@ else ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
# -flto + MinGW gcc + statically-linked antlr4_static produces
# unresolved-reference errors at link time (LTO intermediate objects
# can't see the .a's vtable thunks). -march=native is also a poor
# default for CI binaries shipped to other machines. Keep both on
# Linux/macOS where the optimization actually pays off.
if (MINGW OR WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
else ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto")
endif ()
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g")
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
Expand Down
4 changes: 2 additions & 2 deletions cpp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
plugin's generate goal throw an NPE.
-->
</options>
<sourcePath />
<targetPath />
<sourcePath/>
<targetPath/>
</configuration>
</execution>
<!-- Compile the test code -->
Expand Down
23 changes: 20 additions & 3 deletions cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ message("cmake using: ENABLE_LZOKAY=${ENABLE_LZOKAY}")
option(ENABLE_ZLIB "Enable Zlib compression" ON)
message("cmake using: ENABLE_ZLIB=${ENABLE_ZLIB}")

# ENABLE_SIMD is defined in the top-level CMakeLists.txt
message("cmake using: ENABLE_SIMD=${ENABLE_SIMD}")

message("Running in src directory")
if (${COV_ENABLED})
add_compile_options(-fprofile-arcs -ftest-coverage)
Expand Down Expand Up @@ -89,6 +92,13 @@ if (ENABLE_ANTLR4)
message("Adding ANTLR4 include directory")
endif()

if (ENABLE_SIMD)
add_definitions(-DENABLE_SIMD)
list(APPEND PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/third_party/simde-0.8.4-rc3
)
endif()

include_directories(${PROJECT_INCLUDE_DIR})

# Mark every translation unit that is compiled into the tsfile library so that
Expand Down Expand Up @@ -144,10 +154,17 @@ add_library(tsfile SHARED)

if (${COV_ENABLED})
message("Enable code cov...")
# Apple clang ships coverage runtime via --coverage; libgcov isn't a
# standalone library on macOS. Use --coverage there.
if (APPLE)
set(COV_LINK_LIB --coverage)
else()
set(COV_LINK_LIB -lgcov)
endif()
if (ENABLE_ANTLR4)
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj -lgcov)
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj ${COV_LINK_LIB})
else()
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj -lgcov)
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj ${COV_LINK_LIB})
endif()
else()
message("Disable code cov...")
Expand All @@ -171,4 +188,4 @@ set_target_properties(tsfile PROPERTIES SOVERSION ${LIBTSFILE_SO_VERSION})
install(TARGETS tsfile
RUNTIME DESTINATION ${LIBRARY_OUTPUT_PATH}
LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH}
ARCHIVE DESTINATION ${LIBRARY_OUTPUT_PATH})
ARCHIVE DESTINATION ${LIBRARY_OUTPUT_PATH})
10 changes: 2 additions & 8 deletions cpp/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,15 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} common_SRC_LIST)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/allocator common_allocator_SRC_LIST)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/container common_container_SRC_LIST)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/tsblock common_tsblock_SRC_LIST)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/mutex common_mutex_SRC_LIST)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/datatype common_datatype_SRC_LIST)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(common_obj OBJECT ${common_SRC_LIST}
add_library(common_obj OBJECT ${common_SRC_LIST}
${common_allocator_SRC_LIST}
${common_container_SRC_LIST}
${common_tsblock_SRC_LIST}
${common_mutex_SRC_LIST}
${common_tsblock_SRC_LIST}
${common_datatype_SRC_LIST})

if (ENABLE_ANTLR4)
target_compile_definitions(common_obj PRIVATE ENABLE_ANTLR4)
endif()

# install header files recursively
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
copy_to_dir(${HEADERS} "common_obj")
24 changes: 16 additions & 8 deletions cpp/src/common/allocator/alloc_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,35 +82,43 @@ class ModStat {
}
void init();
void destroy();
INLINE void update_alloc(AllocModID mid, int32_t size) {
INLINE void update_alloc(AllocModID mid, int64_t size) {
#ifdef ENABLE_MEM_STAT
ASSERT(mid < __LAST_MOD_ID);
ATOMIC_FAA(get_item(mid), size);
#endif
}
void update_free(AllocModID mid, uint32_t size) {
void update_free(AllocModID mid, uint64_t size) {
#ifdef ENABLE_MEM_STAT
ASSERT(mid < __LAST_MOD_ID);
ATOMIC_FAA(get_item(mid), 0 - size);
ATOMIC_FAA(get_item(mid), -static_cast<int64_t>(size));
#endif
}
void print_stat();

int64_t get_stat(int8_t mid) {
#ifdef ENABLE_MEM_STAT
if (stat_arr_ != NULL && mid < __LAST_MOD_ID)
return ATOMIC_FAA(get_item(mid), 0LL);
#endif
return 0;
}

#ifdef ENABLE_TEST
int32_t TEST_get_stat(int8_t mid) { return ATOMIC_FAA(get_item(mid), 0); }
int64_t TEST_get_stat(int8_t mid) { return ATOMIC_FAA(get_item(mid), 0LL); }
#endif

private:
INLINE int32_t* get_item(int8_t mid) {
return &(stat_arr_[mid * (ITEM_SIZE / sizeof(int32_t))]);
INLINE int64_t* get_item(int8_t mid) {
return &(stat_arr_[mid * (ITEM_SIZE / sizeof(int64_t))]);
}

private:
static const int32_t ITEM_SIZE = CACHE_LINE_SIZE;
static const int32_t ITEM_COUNT = __LAST_MOD_ID;
int32_t* stat_arr_;
int64_t* stat_arr_;

STATIC_ASSERT((ITEM_SIZE % sizeof(int32_t) == 0), ModStat_ITEM_SIZE_ERROR);
STATIC_ASSERT((ITEM_SIZE % sizeof(int64_t) == 0), ModStat_ITEM_SIZE_ERROR);
};

/* base allocator */
Expand Down
Loading
Loading