[ 
https://issues.apache.org/jira/browse/IGNITE-21464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17815130#comment-17815130
 ] 

Roman Puchkovskiy commented on IGNITE-21464:
--------------------------------------------

I made a dirty test to check how much one thread switch might cost in the 
Embedded mode. I applied the following patch:

{{a/modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java
 
b/modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java}}
{{index ba75082063..8e017c88cd 100644}}
{{--- 
a/modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java}}
{{+++ 
b/modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java}}
{{@@ -246,8 +246,13 @@ public class ReplicaManager extends 
AbstractEventProducer<LocalReplicaEvent, Loc}}
{{ }}
{{         ReplicaRequest request = (ReplicaRequest) message;}}
{{ }}
{{-        ExecutorService stripeExecutor = 
ReplicationGroupStripes.stripeFor(request.groupId(), requestsExecutor);}}
{{-        stripeExecutor.execute(() -> handleReplicaRequest(request, 
senderConsistentId, correlationId));}}
{{+        if 
(Thread.currentThread().getName().contains("MessagingService-inbound")) {}}
{{+            // The request is from the network.}}
{{+            ExecutorService stripeExecutor = 
ReplicationGroupStripes.stripeFor(request.groupId(), requestsExecutor);}}
{{+            stripeExecutor.execute(() -> handleReplicaRequest(request, 
senderConsistentId, correlationId));}}
{{+        } else {}}
{{+            handleReplicaRequest(request, senderConsistentId, 
correlationId);}}
{{+        }}}
{{     }}}
{{ }}
{{     private void handleReplicaRequest(ReplicaRequest request, String 
senderConsistentId, @Nullable Long correlationId) {}}

It basically makes sure that, if a ReplicaRequest comes from the same node (and 
not from the network), we don't switch it to another thread and just proceed in 
the current thread.

For a scenario of 300k PUTs, this caused throughput to increase from 2976 to 
3168 op/sec.

For a scenario of 300k GETs, this increased throughput from 15921 to 19293 
op/sec.

Both scenarios are about Embedded mode (so no Thin Client) on a 1-node cluster.

> Reduce the number of context switches
> -------------------------------------
>
>                 Key: IGNITE-21464
>                 URL: https://issues.apache.org/jira/browse/IGNITE-21464
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vladislav Pyatkov
>            Priority: Major
>              Labels: ignite-3
>
> h3. Motivation
> We move the flow of execution from one thread to another. Each time, it 
> decreases the performance of an operation, especially in the case of embedded 
> mode.
> Probably, we can avoid context switching in particular conditions (embed mode 
> or any other circumstance where the execution thread is already fit for the 
> operation).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to