[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #2861: ARTEMIS-2515 pageIterator.hasNext spends too much time in the case of no messages matched

2019-10-11 Thread GitBox
clebertsuconic commented on a change in pull request #2861: ARTEMIS-2515 
pageIterator.hasNext spends too much time in the case of no messages matched
URL: https://github.com/apache/activemq-artemis/pull/2861#discussion_r334007680
 
 

 ##
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
 ##
 @@ -2942,7 +2946,14 @@ private void depage(final boolean scheduleExpiry) {
   this.directDeliver = false;
 
   int depaged = 0;
-  while (timeout > System.currentTimeMillis() && needsDepage() && 
pageIterator.hasNext()) {
+  while (timeout > System.nanoTime() && needsDepage()) {
+ int status = pageIterator.tryNext();
+ if (status == 2) {
+continue;
+ } else if (status == 0) {
+break;
+ }
+
 
 Review comment:
   Same here


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #2861: ARTEMIS-2515 pageIterator.hasNext spends too much time in the case of no messages matched

2019-10-11 Thread GitBox
clebertsuconic commented on a change in pull request #2861: ARTEMIS-2515 
pageIterator.hasNext spends too much time in the case of no messages matched
URL: https://github.com/apache/activemq-artemis/pull/2861#discussion_r334007365
 
 

 ##
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
 ##
 @@ -2680,24 +2684,24 @@ private boolean deliver() {
 
   int handled = 0;
 
-  long timeout = System.currentTimeMillis() + DELIVERY_TIMEOUT;
+  long timeout = System.nanoTime() + 
TimeUnit.MILLISECONDS.toNanos(DELIVERY_TIMEOUT);
   consumers.reset();
   while (true) {
  if (handled == MAX_DELIVERIES_IN_LOOP) {
 // Schedule another one - we do this to prevent a single thread 
getting caught up in this loop for too
 // long
 
-deliverAsync();
+deliverAsync(true);
 
 return false;
  }
 
- if (System.currentTimeMillis() > timeout) {
+ if (System.nanoTime() > timeout) {
 
 Review comment:
   I remember not long ago, we had to change a few nanoTime operations to avoid 
overflow.
   
   I think, based on that the correct would be System.nanoTime() - timeout > 0
   
   There was a previous big commit where we changed a few like this... the 
commit I could find where Franz changed something similar was 
35c3475092576e7b008220f7c39b78e15850d5fd
   
   
   Can you make that change here please?
   
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services