[
https://issues.apache.org/jira/browse/CASSANDRA-21429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dmitry Konstantinov updated CASSANDRA-21429:
--------------------------------------------
Attachment: CASSANDRA-21429-trunk_ci_summary.htm.zip
> 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
> Fix For: 6.x, 7.x
>
> Attachments: CASSANDRA-21429-6.0_ci_summary.htm.zip,
> CASSANDRA-21429-trunk_ci_summary.htm.zip
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> 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: [email protected]
For additional commands, e-mail: [email protected]