From 445a4b669a3a7232a18bf23340c5f7d580aa92c7 Mon Sep 17 00:00:00 2001 From: Wang Yuan Date: Thu, 17 Sep 2020 21:01:45 +0800 Subject: Implement redisAtomic to replace _Atomic C11 builtin (#7707) Redis 6.0 introduces I/O threads, it is so cool and efficient, we use C11 _Atomic to establish inter-thread synchronization without mutex. But the compiler that must supports C11 _Atomic can compile redis code, that brings a lot of inconvenience since some common platforms can't support by default such as CentOS7, so we want to implement redis atomic type to make it more portable. We have implemented our atomic variable for redis that only has 'relaxed' operations in src/atomicvar.h, so we implement some operations with 'sequentially-consistent', just like the default behavior of C11 _Atomic that can establish inter-thread synchronization. And we replace all uses of C11 _Atomic with redis atomic variable. Our implementation of redis atomic variable uses C11 _Atomic, __atomic or __sync macros if available, it supports most common platforms, and we will detect automatically which feature we use. In Makefile we use a dummy file to detect if the compiler supports C11 _Atomic. Now for gcc, we can compile redis code theoretically if your gcc version is not less than 4.1.2(starts to support __sync_xxx operations). Otherwise, we remove use mutex fallback to implement redis atomic variable for performance and test. You will get compiling errors if your compiler doesn't support all features of above. For cover redis atomic variable tests, we add other CI jobs that build redis on CentOS6 and CentOS7 and workflow daily jobs that run the tests on them. For them, we just install gcc by default in order to cover different compiler versions, gcc is 4.4.7 by default installation on CentOS6 and 4.8.5 on CentOS7. We restore the feature that we can test redis with Helgrind to find data race errors. But you need install Valgrind in the default path configuration firstly before running your tests, since we use macros in helgrind.h to tell Helgrind inter-thread happens-before relationship explicitly for avoiding false positives. Please open an issue on github if you find data race errors relate to this commit. Unrelated: - Fix redefinition of typedef 'RedisModuleUserChangedFunc' For some old version compilers, they will report errors or warnings, if we re-define function type. --- .github/workflows/daily.yml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to '.github/workflows/daily.yml') diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 087b9f2ef..1ccd99805 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -124,12 +124,33 @@ jobs: - uses: actions/checkout@v2 - name: make run: | - yum -y install centos-release-scl - yum -y install devtoolset-7 - scl enable devtoolset-7 "make" + yum -y install gcc make + make - name: test run: | - yum -y install tcl + yum -y install which tcl + ./runtest --accurate --verbose + - name: module api test + run: ./runtest-moduleapi --verbose + - name: sentinel tests + run: ./runtest-sentinel + - name: cluster tests + run: ./runtest-cluster + + test-centos6-jemalloc: + runs-on: ubuntu-latest + if: github.repository == 'redis/redis' + container: centos:6 + timeout-minutes: 14400 + steps: + - uses: actions/checkout@v1 + - name: make + run: | + yum -y install gcc make + make + - name: test + run: | + yum -y install which tcl util-linux-ng ./runtest --accurate --verbose - name: module api test run: ./runtest-moduleapi --verbose -- cgit v1.2.1