You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2025/01/05 17:51:31 UTC

[PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

He-Pin opened a new pull request, #1688:
URL: https://github.com/apache/pekko/pull/1688

   Motivation:
   Call methods directly on ArrayDequeue to avoid forwarding.
   
   Modification:
   Call methods directly on ArrayDequeue to avoid forwarding.
   
   Result:
   performant better


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903553682


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   Do you suggest me remove other changes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903553682


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   Do you suggest me remove this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903339429


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   isn't this the only line that needs to change?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903469642


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   yes it is 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #1688:
URL: https://github.com/apache/pekko/pull/1688


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903471328


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   The others are lint problem 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903948338


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {
     @tailrec final def processBatch(batch: AbstractBatch): Unit =
       if ((batch eq this) && !batch.isEmpty) {
-        batch.poll().run()
+        batch.pollFirst().run()

Review Comment:
   I think current chagne should be fine to include the lint fix .



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. [pekko]

Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof commented on code in PR #1688:
URL: https://github.com/apache/pekko/pull/1688#discussion_r1903958707


##########
actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala:
##########
@@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor {
   // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
   private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
 
-  private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable {
+  private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable {

Review Comment:
   (the reasoning here is to disambiguate between `scala.collection.mutable.ArrayDequeu` and `java.util.ArrayDeque` - that's fair I suppose. It might be even more readable to have the full `java.util.ArrayDeque` here instead of importing `java.util`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org