[ 
https://issues.apache.org/jira/browse/ARTEMIS-2321?focusedWorklogId=235494&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-235494
 ]

ASF GitHub Bot logged work on ARTEMIS-2321:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Apr/19 19:45
            Start Date: 30/Apr/19 19:45
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on pull request #2645: 
ARTEMIS-2321 Paging scalability and GC improvement
URL: https://github.com/apache/activemq-artemis/pull/2645#discussion_r279907383
 
 

 ##########
 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:
   @franz1981 yes, you're right... it won't work with multiple Threads.. I 
don't know what to do on that case.
   
   perhaps we need multiple Components.. but I would on that case use a 
ThreadLocal or some other cache. I don't know.
 
----------------------------------------------------------------
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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 235494)
    Time Spent: 9h 40m  (was: 9.5h)

> Paging scalability and GC improvements
> --------------------------------------
>
>                 Key: ARTEMIS-2321
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2321
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>          Components: Broker
>    Affects Versions: 2.8.0
>            Reporter: Francesco Nigro
>            Priority: Major
>             Fix For: 2.9.0
>
>          Time Spent: 9h 40m
>  Remaining Estimate: 0h
>
> PageCursorProviderImpl::getPageCache's on cache miss is blocking the whole 
> softCache until the requested page isn't fully read, making other threads 
> unable to make progress by querying the cache.
> It would be better to make the page read operation a non-blocking operation 
> for the whole cache, allowing threads that need different pageId to make 
> progress.
> Other improvements:
> * PageCursorProviderImpl can use specialized primitive hash maps to reduce 
> memory footprint (that would cause some page entries to be collected 
> prematurely)
> * PageCache children can avoid to maintain a reference to a Page
> * PagingStoreImpl perform many unnecessary volatile stores/loads and some 
> fields can be turned into plain ones, avoiding expensive atomic operations



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to