franz1981 commented on a change in pull request #2645: ARTEMIS-2321 Paging 
scalability and GC improvement
URL: https://github.com/apache/activemq-artemis/pull/2645#discussion_r279617994
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java
 ##########
 @@ -132,43 +156,88 @@ public PagedReference newReference(final PagePosition 
pos,
    @Override
    public PageCache getPageCache(final long pageId) {
       try {
+         if (pageId > pagingStore.getCurrentWritingPage()) {
+            return null;
+         }
+         boolean createPage = false;
+         CompletableFuture<PageCache> inProgressReadPage;
          PageCache cache;
+         Page page = null;
          synchronized (softCache) {
-            if (pageId > pagingStore.getCurrentWritingPage()) {
+            cache = softCache.get(pageId);
+            if (cache != null) {
+               return cache;
+            }
+            if (!pagingStore.checkPageFileExists((int) pageId)) {
                return null;
             }
-
-            cache = softCache.get(pageId);
-            if (cache == null) {
-               if (!pagingStore.checkPageFileExists((int) pageId)) {
-                  return null;
-               }
-
+            inProgressReadPage = inProgressReadPages.get(pageId);
+            if (inProgressReadPage == null) {
+               final CompletableFuture<PageCache> readPage = new 
CompletableFuture<>();
                cache = createPageCache(pageId);
-               // anyone reading from this cache will have to wait reading to 
finish first
-               // we also want only one thread reading this cache
-               logger.tracef("adding pageCache pageNr=%d into cursor = %s", 
pageId, this.pagingStore.getAddress());
-               readPage((int) pageId, cache);
-               softCache.put(pageId, cache);
+               page = pagingStore.createPage((int) pageId);
+               createPage = true;
+               inProgressReadPage = readPage;
+               inProgressReadPages.put(pageId, readPage);
             }
          }
+         //We need to create a new criticalComponent each time, because
+         //each read page action can happen from a different thread
+         final CriticalComponent readPageActionComponent;
+         if (criticalAnalyzer == null) {
+            readPageActionComponent = null;
+         } else {
+            final SimpleString address = pagingStore.getAddress();
+            readPageActionComponent = new 
CriticalComponentImpl(criticalAnalyzer, PAGE_CURSOR_PROVIDER_CRITICAL_PATHS) {
 
 Review comment:
   I have no idea, maybe yes, but I don't want to make this code more complex 
then necessary: consider that on each `Page::read` request we already create 1 
`CompleableFuture` and each completed read will produce several Paged messages 
as well.
   Saving just 1 instance of CriticalComponentImpl maybe is not a super-win...
   I'm more concerned from a functional point of view instead:  in this version 
I'm triggering the critical analyzer in both cases ie on Page::read and on who 
is waiting for it. 
   Probably I can just leave the critical analyzer to monitor Page:.read and 
logging otherwise.. @clebertsuconic wdyt?

----------------------------------------------------------------
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

Reply via email to