You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Dmitry Konstantinov (Jira)" <ji...@apache.org> on 2026/06/04 10:53:00 UTC
[jira] [Assigned] (CASSANDRA-21429) SEPExecutor#maybeExecuteImmediately not always run tasks immediate even if there is worker capacity
[ https://issues.apache.org/jira/browse/CASSANDRA-21429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dmitry Konstantinov reassigned CASSANDRA-21429:
-----------------------------------------------
Assignee: Dmitry Konstantinov
> SEPExecutor#maybeExecuteImmediately not always run tasks immediate even if there is worker capacity
> ---------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-21429
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21429
> Project: Apache Cassandra
> Issue Type: Improvement
> Components: Local/Other
> Reporter: Dmitry Konstantinov
> Assignee: Dmitry Konstantinov
> Priority: Normal
>
> Ad-hoc metrics:
> {code:java}
> INFO [SEPExecutor-maybeExecuteImmediately-stats] 2026-06-03T19:32:35,526 SEPExecutor.java:70 - SEPExecutor.maybeExecuteImmediately stats: total=15000018, addTask=876687, ratio=0.05844572986512416 {code}
> so, under read stress load we may get ~6% of scheduled tasks in a different thread even if ReadStage pool size > Native-Transport pool size
> {code:java}
> public void maybeExecuteImmediately(Runnable task)
> {
> task = taskFactory.toExecute(task);
> if (!takeWorkPermit(false))
> { addTask(task); // <== we can get into this branch even if we have worker permits
> }
> else
> {
> try
> {
> task.run();
> }
> finally
> {
> returnWorkPermit();
> // we have to maintain our invariant of always scheduling after any work is performed
> // in this case in particular we are not processing the rest of the queue anyway, and so
> // the work permit may go wasted if we don't immediately attempt to spawn another worker
> maybeSchedule();
> }
> }
> } {code}
> {code}
> boolean takeWorkPermit(boolean takeTaskPermit)
> {
> int taskDelta = takeTaskPermit ? 1 : 0;
> while (true)
> {
> long current = permits.get();
> int workPermits = workPermits(current);
> int taskPermits = taskPermits(current);
> if (workPermits <= 0 || taskPermits == 0) // <== if we do not have in progress tasks we return false here
> return false;
> if (permits.compareAndSet(current, combine(taskPermits - taskDelta, workPermits - 1)))
> {
> return true;
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org