Skip to content

Commit 32162cf

Browse files
committed
Change default for cassandra.set_sep_thread_name to false to reduce CPU usage
Add an extra optimization if it is enabled: invoke Thread.setName only if a phase changed patch by Dmitry Konstantinov; reviewed by Francisco Guerrero, Jyothsna Konisa for CASSANDRA-21089
1 parent 7b3514d commit 32162cf

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
6.0-alpha2
2+
* Change default for cassandra.set_sep_thread_name to false to reduce CPU usage (CASSANDRA-21089)
23
* Avoid permission checks for masked columns when the table doesn't have any (CASSANDRA-21299)
34
* Reduce allocations and array copies due to buffer resizing in LocalDataResponse during row serialization (CASSANDRA-21285)
45
* Implement a guardrail for client driver versions (CASSANDRA-21146)

src/java/org/apache/cassandra/concurrent/SEPWorker.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ final class SEPWorker extends AtomicReference<SEPWorker.Work> implements Runnabl
5353

5454
private final AtomicReference<Runnable> currentTask = new AtomicReference<>();
5555

56+
private String lastUsedExecutorName;
57+
5658
SEPWorker(ThreadGroup threadGroup, Long workerId, Work initialState, SharedExecutorPool pool)
5759
{
5860
this.pool = pool;
@@ -129,8 +131,11 @@ public void run()
129131
assigned = get().assigned;
130132
if (assigned == null)
131133
continue;
132-
if (SET_THREAD_NAME)
134+
if (SET_THREAD_NAME && assigned.name != lastUsedExecutorName) // .equals is not used intentionally
135+
{
133136
Thread.currentThread().setName(assigned.name + workerIdThreadSuffix);
137+
lastUsedExecutorName = assigned.name;
138+
}
134139

135140
task = assigned.tasks.poll();
136141
currentTask.lazySet(task);

src/java/org/apache/cassandra/config/CassandraRelevantProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ public enum CassandraRelevantProperties
536536
*/
537537
SEED_COUNT_WARN_THRESHOLD("cassandra.seed_count_warn_threshold"),
538538
SERIALIZATION_EMPTY_TYPE_NONEMPTY_BEHAVIOR("cassandra.serialization.emptytype.nonempty_behavior"),
539-
SET_SEP_THREAD_NAME("cassandra.set_sep_thread_name", "true"),
539+
SET_SEP_THREAD_NAME("cassandra.set_sep_thread_name", "false"),
540540
SHUTDOWN_ANNOUNCE_DELAY_IN_MS("cassandra.shutdown_announce_in_ms", "2000"),
541541
SIMULATOR_ITERATIONS("simulator.iterations", "3"),
542542
SIMULATOR_SEED("cassandra.simulator.seed"),

0 commit comments

Comments
 (0)