Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
j8_jvm_upgrade_dtests:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
j8_cqlsh-dtests-py2-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
j11_unit_tests:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:
j8_cqlsh-dtests-py38-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -340,7 +340,7 @@ jobs:
j11_cqlsh-dtests-py3-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -418,7 +418,7 @@ jobs:
j11_cqlsh-dtests-py3-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -496,7 +496,7 @@ jobs:
j11_cqlsh-dtests-py38-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -574,7 +574,7 @@ jobs:
j8_cqlsh-dtests-py3-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -651,7 +651,7 @@ jobs:
j8_cqlsh-dtests-py2-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -728,7 +728,7 @@ jobs:
j11_cqlsh-dtests-py2-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -806,7 +806,7 @@ jobs:
j11_dtests-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -887,7 +887,7 @@ jobs:
j8_dtests-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -945,7 +945,7 @@ jobs:
j8_upgradetests-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1044,7 +1044,7 @@ jobs:
utests_stress:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -1089,7 +1089,7 @@ jobs:
j8_unit_tests:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1180,10 +1180,10 @@ jobs:
j11_jvm_dtests:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
parallelism: 2
steps:
- attach_workspace:
at: /home/cassandra
Expand Down Expand Up @@ -1272,7 +1272,7 @@ jobs:
j11_build:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -1353,7 +1353,7 @@ jobs:
j11_cqlsh-dtests-py2-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1431,7 +1431,7 @@ jobs:
j8_dtests-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1489,7 +1489,7 @@ jobs:
j11_cqlsh-dtests-py38-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1567,10 +1567,10 @@ jobs:
j8_jvm_dtests:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
parallelism: 2
steps:
- attach_workspace:
at: /home/cassandra
Expand Down Expand Up @@ -1658,7 +1658,7 @@ jobs:
j8_build:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -1738,7 +1738,7 @@ jobs:
j8_cqlsh-dtests-py3-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1815,7 +1815,7 @@ jobs:
j8_cqlsh-dtests-py38-with-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -1892,7 +1892,7 @@ jobs:
utests_long:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: xlarge
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -1937,7 +1937,7 @@ jobs:
utests_fqltool:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down Expand Up @@ -1982,7 +1982,7 @@ jobs:
j11_dtests-no-vnodes:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -2063,7 +2063,7 @@ jobs:
utests_compression:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 4
Expand Down Expand Up @@ -2154,7 +2154,7 @@ jobs:
j8_dtest_jars_build:
docker:
- image: nastra/cassandra-testing-ubuntu1910-java11-w-dependencies:20200603
resource_class: medium
resource_class: large
working_directory: ~/
shell: /bin/bash -eo pipefail -l
parallelism: 1
Expand Down
13 changes: 11 additions & 2 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,22 @@ concurrent_counter_writes: 32
# be limited by the less of concurrent reads or concurrent writes.
concurrent_materialized_view_writes: 32

# Maximum memory to use for inter-node and client-server networking buffers.
#
# Defaults to the smaller of 1/16 of heap or 128MB. This pool is allocated off-heap,
# so is in addition to the memory allocated for heap. The cache also has on-heap
# overhead which is roughly 128 bytes per chunk (i.e. 0.2% of the reserved size
# if the default 64k chunk size is used).
# Memory is only allocated when needed.
# networking_cache_size_in_mb: 128

# 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.
# 32MB of this are reserved for pooling buffers, the rest is used for chunk cache
# that holds uncompressed sstable chunks.
# Defaults to the smaller of 1/4 of heap or 512MB. This pool is allocated off-heap,
# so is in addition to the memory allocated for heap. The cache also has on-heap
# overhead which is roughly 128 bytes per chunk (i.e. 0.2% of the reserved size
Expand Down
14 changes: 9 additions & 5 deletions src/java/org/apache/cassandra/cache/ChunkCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.cassandra.io.util.*;
import org.apache.cassandra.metrics.ChunkCacheMetrics;
import org.apache.cassandra.utils.memory.BufferPool;
import org.apache.cassandra.utils.memory.BufferPools;

public class ChunkCache
implements CacheLoader<ChunkCache.Key, ChunkCache.Buffer>, RemovalListener<ChunkCache.Key, ChunkCache.Buffer>, CacheSize
Expand All @@ -43,7 +44,9 @@ public class ChunkCache
public static final boolean roundUp = DatabaseDescriptor.getFileCacheRoundUp();

private static boolean enabled = DatabaseDescriptor.getFileCacheEnabled() && cacheSize > 0;
public static final ChunkCache instance = enabled ? new ChunkCache() : null;
public static final ChunkCache instance = enabled ? new ChunkCache(BufferPools.forChunkCache()) : null;

private final BufferPool bufferPool;

private final LoadingCache<Key, Buffer> cache;
public final ChunkCacheMetrics metrics;
Expand Down Expand Up @@ -86,7 +89,7 @@ public boolean equals(Object obj)
}
}

static class Buffer implements Rebufferer.BufferHolder
class Buffer implements Rebufferer.BufferHolder
{
private final ByteBuffer buffer;
private final long offset;
Expand Down Expand Up @@ -130,12 +133,13 @@ public long offset()
public void release()
{
if (references.decrementAndGet() == 0)
BufferPool.put(buffer);
bufferPool.put(buffer);
}
}

private ChunkCache()
private ChunkCache(BufferPool pool)
{
bufferPool = pool;
metrics = new ChunkCacheMetrics(this);
cache = Caffeine.newBuilder()
.maximumWeight(cacheSize)
Expand All @@ -149,7 +153,7 @@ private ChunkCache()
@Override
public Buffer load(Key key)
{
ByteBuffer buffer = BufferPool.get(key.file.chunkSize(), key.file.preferredBufferType());
ByteBuffer buffer = bufferPool.get(key.file.chunkSize(), key.file.preferredBufferType());
assert buffer != null;
key.file.readChunk(key.position, buffer);
return new Buffer(buffer, key.position);
Expand Down
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ public class Config
private static boolean isClientMode = false;
private static Supplier<Config> overrideLoadConfig = null;

public Integer networking_cache_size_in_mb;

public Integer file_cache_size_in_mb;

public boolean file_cache_enabled = Boolean.getBoolean("cassandra.file_cache_enabled");
Expand Down
14 changes: 14 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ else if (conf.disk_access_mode == Config.DiskAccessMode.mmap_index_only)
if (conf.concurrent_replicates != null)
logger.warn("concurrent_replicates has been deprecated and should be removed from cassandra.yaml");

if (conf.networking_cache_size_in_mb == null)
conf.networking_cache_size_in_mb = Math.min(128, (int) (Runtime.getRuntime().maxMemory() / (16 * 1048576)));

if (conf.file_cache_size_in_mb == null)
conf.file_cache_size_in_mb = Math.min(512, (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)));

Expand Down Expand Up @@ -2449,6 +2452,17 @@ public static int getFileCacheSizeInMB()
return conf.file_cache_size_in_mb;
}

public static int getNetworkingCacheSizeInMB()
{
if (conf.networking_cache_size_in_mb == null)
{
// In client mode the value is not set.
assert DatabaseDescriptor.isClientInitialized();
return 0;
}
return conf.networking_cache_size_in_mb;
}

public static boolean getFileCacheRoundUp()
{
if (conf.file_cache_round_up == null)
Expand Down
Loading