Skip to content

Commit c31eeea

Browse files
eolivellidjatnieks
authored andcommitted
CNDB-12257: do not call System.getProperty on an hotpath (ChunkCache miss) (#1475)
1 parent 17f983b commit c31eeea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/java/org/apache/cassandra/cache/ChunkCache.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import org.apache.cassandra.concurrent.ParkedExecutor;
5050
import org.apache.cassandra.concurrent.ShutdownableExecutor;
51+
import org.apache.cassandra.config.CassandraRelevantProperties;
5152
import org.apache.cassandra.config.DatabaseDescriptor;
5253
import org.apache.cassandra.io.sstable.CorruptSSTableException;
5354
import org.apache.cassandra.io.util.ChannelProxy;
@@ -61,7 +62,6 @@
6162
import static org.apache.cassandra.config.CassandraRelevantProperties.CHUNKCACHE_ASYNC_CLEANUP;
6263
import static org.apache.cassandra.config.CassandraRelevantProperties.CHUNKCACHE_CLEANER_THREADS;
6364
import static org.apache.cassandra.config.CassandraRelevantProperties.CHUNKCACHE_INITIAL_CAPACITY;
64-
import static org.apache.cassandra.config.CassandraRelevantProperties.CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS;
6565

6666
public class ChunkCache
6767
implements RemovalListener<ChunkCache.Key, ChunkCache.Buffer>, CacheSize
@@ -74,6 +74,8 @@ public class ChunkCache
7474
private static final int CLEANER_THREADS = CHUNKCACHE_CLEANER_THREADS.getInt();
7575

7676
private static final Class PERFORM_CLEANUP_TASK_CLASS;
77+
// cached value in order to not call System.getProperty on a hotpath
78+
private static final int CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS = CassandraRelevantProperties.CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS.getInt();
7779

7880
static
7981
{
@@ -424,12 +426,12 @@ public BufferHolder rebuffer(long position)
424426
}
425427
else
426428
{
427-
chunk = existing.get(CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS.getInt(), TimeUnit.MILLISECONDS);
429+
chunk = existing.get(CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
428430
}
429431
}
430432
else
431433
{
432-
chunk = cachedValue.get(CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS.getInt(), TimeUnit.MILLISECONDS);
434+
chunk = cachedValue.get(CHUNK_CACHE_REBUFFER_WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
433435
}
434436

435437
buf = chunk.reference();

0 commit comments

Comments
 (0)