]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
compressor/zlib: add compressor_zlib_isal config option to disable ISA-L
authorSage Weil <sage@redhat.com>
Thu, 6 Oct 2016 15:49:14 +0000 (11:49 -0400)
committerSage Weil <sage@redhat.com>
Thu, 6 Oct 2016 19:36:08 +0000 (15:36 -0400)
We dynamically enable this if the necessary processor features are present.
Allow this probing to be disabled explicitly.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/compressor/zlib/CompressionPluginZlib.cc
src/test/compressor/test_compression.cc

index 312b8edf36bab5de5c1fa3ede97fa36141ca2ea2..f197d30ee521b55e57916ec9af4b2b7982bf448d 100644 (file)
@@ -97,6 +97,8 @@ OPTION(xio_max_conns_per_portal, OPT_INT, 32) // max xio_connections per portal/
 OPTION(xio_transport_type, OPT_STR, "rdma") // xio transport type: {rdma or tcp}
 OPTION(xio_max_send_inline, OPT_INT, 512) // xio maximum threshold to send inline
 
+OPTION(compressor_zlib_isal, OPT_BOOL, true)
+
 OPTION(async_compressor_enabled, OPT_BOOL, false)
 OPTION(async_compressor_type, OPT_STR, "snappy")
 OPTION(async_compressor_threads, OPT_INT, 2)
index e330d095a1e9be9a3f2bccf79c67cf6eeebacb4d..d0e90eca1976c36bdb606e550f08c35c5412bb75 100644 (file)
@@ -27,6 +27,7 @@
 
 class CompressionPluginZlib : public CompressionPlugin {
 public:
+  bool has_isal = false;
 
   explicit CompressionPluginZlib(CephContext *cct) : CompressionPlugin(cct)
   {}
@@ -34,11 +35,16 @@ public:
   virtual int factory(CompressorRef *cs,
                       ostream *ss)
   {
-    if (compressor == 0) {
+    bool isal;
+    if (cct->_conf->compressor_zlib_isal) {
       ceph_arch_probe();
-      bool isal = (ceph_arch_intel_pclmul && ceph_arch_intel_sse41);
-      ZlibCompressor *interface = new ZlibCompressor(isal);
-      compressor = CompressorRef(interface);
+      isal = (ceph_arch_intel_pclmul && ceph_arch_intel_sse41);
+    } else {
+      isal = false;
+    }
+    if (compressor == 0 || has_isal != isal) {
+      compressor = CompressorRef(new ZlibCompressor(isal));
+      has_isal = isal;
     }
     *cs = compressor;
     return 0;
index 12e49b655d4270a4f4e62c429b83572a4539c871..9dfe83494c357aeaa53f6d0252411623cbefd6f3 100644 (file)
 class CompressionTest : public ::testing::Test,
                        public ::testing::WithParamInterface<const char*> {
 public:
+  std::string plugin;
   CompressorRef compressor;
 
+  CompressionTest() {
+    plugin = GetParam();
+    size_t pos = plugin.find('/');
+    if (pos != std::string::npos) {
+      string isal = plugin.substr(pos + 1);
+      plugin = plugin.substr(0, pos);
+      if (isal == "isal") {
+       g_conf->set_val("compressor_zlib_isal", "true");
+       g_ceph_context->_conf->apply_changes(NULL);
+      } else if (isal == "noisal") {
+       g_conf->set_val("compressor_zlib_isal", "false");
+       g_ceph_context->_conf->apply_changes(NULL);
+      } else {
+       assert(0 == "bad option");
+      }
+    }
+    cout << "[plugin " << plugin << " (" << GetParam() << ")]" << std::endl;
+  }
+
   void SetUp() {
-    compressor = Compressor::create(g_ceph_context, GetParam());
+    compressor = Compressor::create(g_ceph_context, plugin);
     ASSERT_TRUE(compressor);
   }
   void TearDown() {
@@ -133,7 +153,8 @@ INSTANTIATE_TEST_CASE_P(
   Compression,
   CompressionTest,
   ::testing::Values(
-    "zlib",
+    "zlib/isal",
+    "zlib/noisal",
     "snappy"));
 
 int main(int argc, char **argv) {