Skip to content

Commit

Permalink
Add flag to disable chunk cache and disable by default
Browse files Browse the repository at this point in the history
patch by David Capwell; reviewed by Jon Meredith, Zhao Yang for CASSANDRA-16036
  • Loading branch information
dcapwell committed Sep 29, 2020
1 parent c6ef476 commit d4f5018
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions conf/cassandra.yaml
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/cache/ChunkCache.java
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Expand Up @@ -2432,6 +2432,11 @@ public static void setIncrementalBackupsEnabled(boolean value)
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)
Expand Down
1 change: 1 addition & 0 deletions test/conf/cassandra.yaml
Expand Up @@ -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

0 comments on commit d4f5018

Please sign in to comment.