You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2020/09/30 00:07:35 UTC

[cassandra] branch trunk updated: Add flag to disable chunk cache and disable by default

This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 79e693e  Add flag to disable chunk cache and disable by default
79e693e is described below

commit 79e693e16e2152097c5b27d2d7aaa1763e34f594
Author: David Capwell <dc...@apache.org>
AuthorDate: Tue Sep 29 15:26:37 2020 -0700

    Add flag to disable chunk cache and disable by default
    
    patch by David Capwell; reviewed by Jon Meredith, Zhao Yang for CASSANDRA-16036
---
 CHANGES.txt                                                  | 1 +
 conf/cassandra.yaml                                          | 4 ++++
 src/java/org/apache/cassandra/cache/ChunkCache.java          | 2 +-
 src/java/org/apache/cassandra/config/Config.java             | 2 ++
 src/java/org/apache/cassandra/config/DatabaseDescriptor.java | 5 +++++
 test/conf/cassandra.yaml                                     | 1 +
 6 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 190eebc..d1fa00e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -16,6 +16,7 @@
  * Mutating sstable component may race with entire-sstable-streaming(ZCS) causing checksum validation failure (CASSANDRA-15861)
  * NPE thrown while updating speculative execution time if keyspace is removed during task execution (CASSANDRA-15949)
  * Show the progress of data streaming and index build (CASSANDRA-15406)
+ * Add flag to disable chunk cache and disable by default (CASSANDRA-16036)
 Merged from 3.11:
  * Don't attempt value skipping with mixed version cluster (CASSANDRA-15833)
  * Use IF NOT EXISTS for index and UDT create statements in snapshot schema files (CASSANDRA-13935)
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index fcd2ffa..ff414ed 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -469,6 +469,10 @@ concurrent_counter_writes: 32
 # be limited by the less of concurrent reads or concurrent writes.
 concurrent_materialized_view_writes: 32
 
+# Enable the sstable chunk cache.  The chunk cache will store recently accessed
+# sections of the sstable in-memory as uncompressed buffers.
+# file_cache_enabled: false
+
 # Maximum memory to use for sstable chunk cache and buffer pooling.
 # 32MB of this are reserved for pooling buffers, the rest is used as an
 # cache that holds uncompressed sstable chunks.
diff --git a/src/java/org/apache/cassandra/cache/ChunkCache.java b/src/java/org/apache/cassandra/cache/ChunkCache.java
index e370206..ae38015 100644
--- a/src/java/org/apache/cassandra/cache/ChunkCache.java
+++ b/src/java/org/apache/cassandra/cache/ChunkCache.java
@@ -42,7 +42,7 @@ public class ChunkCache
     public static final long cacheSize = 1024L * 1024L * Math.max(0, DatabaseDescriptor.getFileCacheSizeInMB() - RESERVED_POOL_SPACE_IN_MB);
     public static final boolean roundUp = DatabaseDescriptor.getFileCacheRoundUp();
 
-    private static boolean enabled = cacheSize > 0;
+    private static boolean enabled = DatabaseDescriptor.getFileCacheEnabled() && cacheSize > 0;
     public static final ChunkCache instance = enabled ? new ChunkCache() : null;
 
     private final LoadingCache<Key, Buffer> cache;
diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java
index 6abdfba..da410155 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -304,6 +304,8 @@ public class Config
 
     public Integer file_cache_size_in_mb;
 
+    public boolean file_cache_enabled = Boolean.getBoolean("cassandra.file_cache_enabled");
+
     /**
      * Because of the current {@link org.apache.cassandra.utils.memory.BufferPool} slab sizes of 64 kb, we
      * store in the file cache buffers that divide 64 kb, so we need to round the buffer sizes to powers of two.
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 3b5fdfb..e8e66fa 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -2432,6 +2432,11 @@ public class DatabaseDescriptor
         conf.incremental_backups = value;
     }
 
+    public static boolean getFileCacheEnabled()
+    {
+        return conf.file_cache_enabled;
+    }
+
     public static int getFileCacheSizeInMB()
     {
         if (conf.file_cache_size_in_mb == null)
diff --git a/test/conf/cassandra.yaml b/test/conf/cassandra.yaml
index 89b7ff1..38e012f 100644
--- a/test/conf/cassandra.yaml
+++ b/test/conf/cassandra.yaml
@@ -50,3 +50,4 @@ stream_entire_sstables: true
 stream_throughput_outbound_megabits_per_sec: 200000000
 enable_sasi_indexes: true
 enable_materialized_views: true
+file_cache_enabled: true


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org