You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/01/04 14:15:02 UTC

[GitHub] [activemq-artemis] franz1981 opened a new pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

franz1981 opened a new pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


   I've chosen to remove the caching of the last accessed buffer because multiple consumers would scale negatively due to this and instead, let a reloaded live cache to benefit from O(1) accesses while getting a more compacted data representation.
   
   The PR is providing a JMH bench to track perf regression on lookup scaling.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


   I've chosen to remove the caching of the last accessed buffer because multiple consumers would scale negatively due to this and instead, let a reloaded live cache to benefit from O(1) accesses instead, while getting a more compacted data representation instead.
   
   The PR is providing a JMH bench to track perf regression on lookup scaling.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#discussion_r551786170



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
##########
@@ -468,16 +468,11 @@ protected void reloadLivePage(int pageId) throws Exception {
       Page page = createPage(pageId);
       page.open();
 
-      List<PagedMessage> messages = page.read(storageManager);
+      final List<PagedMessage> messages = page.read(storageManager);
 
-      LivePageCache pageCache = new LivePageCacheImpl(pageId);
+      final PagedMessage[] initialMessages = messages.toArray(new PagedMessage[messages.size()]);
 
-      for (PagedMessage msg : messages) {
-         pageCache.addLiveMessage(msg);
-         // As we add back to the live page,
-         // we have to discount one when we read the page
-         msg.getMessage().usageDown();
-      }
+      final LivePageCache pageCache = new LivePageCacheImpl(pageId, initialMessages);

Review comment:
       @clebertsuconic 
   the original `addLiveMessage` was calling `usageUp` right before `usageDown`: it means that they can both be saved as the ref count will remain the same, correct? 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


   I've chosen to remove the caching of the last accessed buffer because multiple consumers would scale negatively due to this and instead, let a reloaded live cache to benefit from O(1) accesses while getting a more compacted data representation.
   
   The PR is providing a JMH bench to track perf regression on lookup scaling and other API changes to remove unused prod methods while better capturing how the page cache mechanism works.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754040778


   I've added @Contended to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] asfgit closed pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757117905






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754040778


   I've added @Contended to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses.
   
   It just means that single consumer cases will benefit a LOT from this, but distanced multiple consumers won't scale as expected: probably we need a better caching strategy.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] michaelandrepearce commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
michaelandrepearce commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757072027


   > I've added `@Contended` to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses.
   > 
   
   Im not seeing this flag being altered/added at all in the commits? 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757117905


   > Im not seeing this flag being altered/added at all in the commits?
   
   Correct: I have used it in a run with JMH while I was trying to improve the page lookup cost of the chunked list, but I have decided that such change was affecting negatively performance, see https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723
   
   The JVM options helped to acknowledge the issue with that solution, but wasn't able to save it to happen, that's why I have chosen to give up with the last accesses buffer caching mechanism.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757117905


   > Im not seeing this flag being altered/added at all in the commits?
   
   Correct: I have used it in a run with JMH while I was trying to improve the page lookup cost of the chunked list, but I have decided that such change was too invasive, see https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] michaelandrepearce commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
michaelandrepearce commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757072027


   > I've added `@Contended` to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses.
   > 
   
   Im not seeing this flag being altered/added at all in the commits? 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757117905


   > Im not seeing this flag being altered/added at all in the commits?
   
   Correct: I have used it in a run with JMH while I was trying to improve the page lookup cost of the chunked list, but I have decided that such change was affecting negatively performance, see https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723
   
   The JVM options helped to acknowledge the issue with that solution, but wasn't able to save it to happen, that's why I have chosen to give up with the last accessed buffer caching mechanism.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


   I've chosen to remove the caching of the last accessed buffer because multiple consumers would scale negatively due to this and instead, let a reloaded live cache to benefit from O(1) accesses while getting a more compacted data representation.
   
   The PR is providing a JMH bench to track perf regression/investigate behaviour on lookup scaling and other API changes to remove unused prod methods while better capturing how the page cache mechanism works.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-753999429


   @qihongxu Hi!! 
   I've tried to address/improve what you've shown in your comment on https://github.com/apache/activemq-artemis/pull/2494#issuecomment-455086939
   Any chances you can test it with that same original test?
   I'm going to provide a micro-bench just on the append only list, but only a end-2-end test can shows if the improvements are effective as expected


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754024920


   Despite my expectations, the results are NOT promising...
   
   This PR
   1 thread:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt          Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  108968555.072 ±  135438.271  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16  105613840.728 ±  475604.647  ops/s
   ```
   3 threads:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt         Score          Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  91693844.669 ± 29399345.167  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16  78520201.713 ±  3428526.469  ops/s
   ```
   
   `master`
   
   1 thread:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt         Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  59747234.340 ± 1117878.317  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16   7699916.690 ±   36448.254  ops/s
   ```
   3 threads:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt          Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  181201564.143 ± 2457478.235  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16   23011863.725 ±  110276.468  ops/s
   ```
   
   It shows that 3 consumers won't get the expected speedup and I suppose that's due to the last accessed buffer miss.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754040778


   I've added `@Contended` to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses.
   
   It just means that single consumer cases will benefit a LOT from this PR, but distanced multiple consumers won't scale as expected: probably we need a better caching strategy.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-757117905


   > Im not seeing this flag being altered/added at all in the commits?
   
   Correct: I have used it in a run with JMH while I was trying to improve the page lookup cost of the chunked list, but I have decided that such change was too invasive, see https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754085723


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754024920


   Despite my expectations, the results are NOT promising...
   
   This PR
   1 thread:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt          Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  108968555.072 ±  135438.271  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16  105613840.728 ±  475604.647  ops/s
   ```
   3 threads:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt         Score          Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  91693844.669 ± 29399345.167  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16  78520201.713 ±  3428526.469  ops/s
   ```
   
   `master`
   
   1 thread:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt         Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  59747234.340 ± 1117878.317  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16   7699916.690 ±   36448.254  ops/s
   ```
   3 threads:
   ```
   Benchmark                                            (chunkSize)  (size)   Mode  Cnt          Score         Error  Units
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32    1000  thrpt   16  181201564.143 ± 2457478.235  ops/s
   ConcurrentAppendOnlyChunkListLookupBenchmark.lookup           32   10000  thrpt   16   23011863.725 ±  110276.468  ops/s
   ```
   
   It shows that 3 consumers won't get the expected speedup and I suppose that's due to the last accessed buffer (concurrent) miss


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-758897104


   I'm running a complete test suite on a rebased branch.. if everything is fine I will merge it.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 commented on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 commented on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-758867948


   The PR should be in a good fit, any other concern?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [activemq-artemis] franz1981 edited a comment on pull request #3393: ARTEMIS-3049 Reduce live page lookup cost

Posted by GitBox <gi...@apache.org>.
franz1981 edited a comment on pull request #3393:
URL: https://github.com/apache/activemq-artemis/pull/3393#issuecomment-754040778


   I've added @Contended to some fields of the list + `--jvmArgs="-XX:-RestrictContended"` and now it seems to work better: it seems that the modifications on cached last accessed buffer have a false sharing with lastIndex accesses.
   
   It just means that single consumer cases will benefit a LOT from this PR, but distanced multiple consumers won't scale as expected: probably we need a better caching strategy.


----------------------------------------------------------------
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:
users@infra.apache.org