From 29f5052c4d348861034dd2021126a8b5a088634a Mon Sep 17 00:00:00 2001
From: Roman Gershman <romange@gmail.com>
Date: Sat, 19 Feb 2022 22:56:09 +0200
Subject: [PATCH] Add alpine-dev container to test matrix

---
 .github/workflows/ci.yml |  9 ++++++---
 core/CMakeLists.txt      |  3 ++-
 core/compact_object.cc   |  3 ++-
 helio                    |  2 +-
 redis/zmalloc.h          | 42 ++++------------------------------------
 5 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 17eb2bb..f21a043 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -10,7 +10,6 @@ on:
 env:
   # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
   BUILD_TYPE: Debug
-  CXX: g++-9
 jobs:
   build:
     # The CMake configure and build commands are platform agnostic and should work equally
@@ -18,9 +17,13 @@ jobs:
     # cross-platform coverage.
     # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
     runs-on: ubuntu-latest
-    timeout-minutes: 90
+    strategy:
+      matrix:
+        # Test of these containers
+        container: ["ubuntu-dev", "alpine-dev"]
+    timeout-minutes: 30
     container: 
-      image: ghcr.io/${{ github.actor }}/ubuntu-dev:latest
+      image: ghcr.io/${{ github.actor }}/${{ matrix.container }}:latest
       credentials:
         username: ${{ github.actor }}
         password: ${{ secrets.GITHUB_TOKEN }}
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index d16011c..34e08a3 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_library(dfly_core  compact_object.cc dragonfly_core.cc interpreter.cc 
             tx_queue.cc)
-cxx_link(dfly_core base absl::flat_hash_map absl::str_format redis_lib TRDP::lua crypto)
+cxx_link(dfly_core base absl::flat_hash_map absl::str_format redis_lib TRDP::lua 
+         Boost::fiber crypto)
 
 cxx_test(dfly_core_test dfly_core LABELS DFLY)
 cxx_test(compact_object_test dfly_core LABELS DFLY)
diff --git a/core/compact_object.cc b/core/compact_object.cc
index b789903..858b64e 100644
--- a/core/compact_object.cc
+++ b/core/compact_object.cc
@@ -85,7 +85,7 @@ void CompactBlob::MakeRoom(size_t current_cap, size_t desired, std::pmr::memory_
 
 // here we break pmr model since we use non-pmr api of fetching usable size based on pointer.
 size_t CompactBlob::capacity() const {
-  return malloc_usable_size(ptr_);
+  return zmalloc_size(ptr_);
 }
 
 size_t RobjWrapper::MallocUsed() const {
@@ -174,6 +174,7 @@ uint64_t RobjWrapper::HashCode() const {
     default:
       LOG(FATAL) << "Unsupported type for hashcode " << type;
   }
+  return 0;
 }
 
 bool RobjWrapper::Equal(const RobjWrapper& ow) const {
diff --git a/helio b/helio
index 84c1b2c..ec055f6 160000
--- a/helio
+++ b/helio
@@ -1 +1 @@
-Subproject commit 84c1b2ca38d077eaae347098e56f451aad2caa2b
+Subproject commit ec055f6bb2476aaebda441cbf1fc3c738bf5a4c6
diff --git a/redis/zmalloc.h b/redis/zmalloc.h
index 95ff49b..5125262 100644
--- a/redis/zmalloc.h
+++ b/redis/zmalloc.h
@@ -37,17 +37,7 @@
 #define __xstr(s) __zm_str(s)
 #define __zm_str(s) #s
 
-#if defined(USE_TCMALLOC)
-#define ZMALLOC_LIB ("tcmalloc-" __xstr(TC_VERSION_MAJOR) "." __xstr(TC_VERSION_MINOR))
-#include <google/tcmalloc.h>
-#if (TC_VERSION_MAJOR == 1 && TC_VERSION_MINOR >= 6) || (TC_VERSION_MAJOR > 1)
-#define HAVE_MALLOC_SIZE 1
-#define zmalloc_size(p) tc_malloc_size(p)
-#else
-#error "Newer version of tcmalloc required"
-#endif
-
-#elif defined(USE_JEMALLOC)
+#if defined(USE_JEMALLOC)
 #define ZMALLOC_LIB ("jemalloc-" __xstr(JEMALLOC_VERSION_MAJOR) "." __xstr(JEMALLOC_VERSION_MINOR) "." __xstr(JEMALLOC_VERSION_BUGFIX))
 #include <jemalloc/jemalloc.h>
 #if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2)
@@ -73,26 +63,18 @@
  */
 #ifndef ZMALLOC_LIB
 #define ZMALLOC_LIB "libc"
-#if !defined(NO_MALLOC_USABLE_SIZE) && \
-    (defined(__GLIBC__) || defined(__FreeBSD__) || \
-     defined(USE_MALLOC_USABLE_SIZE))
 
-/* Includes for malloc_usable_size() */
-#ifdef __FreeBSD__
-#include <malloc_np.h>
-#else
 #include <malloc.h>
-#endif
 
 #define HAVE_MALLOC_SIZE 1
 #ifdef USE_ZMALLOC_MI
 #define zmalloc_size(p) zmalloc_usable_size(p)
-#else 
+#else
 #define zmalloc_size(p) malloc_usable_size(p)
-#endif 
-#endif
 #endif
 
+#endif  // ZMALLOC_LIB
+
 /* We can enable the Redis defrag capabilities only if we are using Jemalloc
  * and the version used is our special version modified for Redis having
  * the ability to return per-allocation fragmentation hints. */
@@ -131,22 +113,6 @@ size_t zmalloc_usable_size(const void* p);
 
 // roman: void zlibc_free(void *ptr);
 
-#ifdef HAVE_DEFRAG
-void zfree_no_tcache(void *ptr);
-void *zmalloc_no_tcache(size_t size);
-#endif
-
-#ifndef HAVE_MALLOC_SIZE
-size_t zmalloc_size(void *ptr);
-size_t zmalloc_usable_size(void *ptr);
-#else
-// #define zmalloc_usable_size(p) zmalloc_size(p)
-#endif
-
-#ifdef REDIS_TEST
-int zmalloc_test(int argc, char **argv, int accurate);
-#endif
-
 extern __thread ssize_t used_memory_tl;
 void init_zmalloc_threadlocal();