activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franz1981 <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #2494: ARTEMIS-2224 Reduce contention on LiveP...
Date Wed, 09 Jan 2019 22:25:20 GMT
Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2494#discussion_r246569626
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java
---
    @@ -48,54 +82,228 @@ public long getPageId() {
        }
     
        @Override
    -   public synchronized int getNumberOfMessages() {
    -      return messages.size();
    +   public int getNumberOfMessages() {
    +      while (true) {
    +         final long size = producerIndex;
    +         if (size == RESIZING) {
    +            Thread.yield();
    +            continue;
    +         }
    +         return (int) Math.min(size, Integer.MAX_VALUE);
    +      }
        }
     
        @Override
    -   public synchronized void setMessages(PagedMessage[] messages) {
    +   public void setMessages(PagedMessage[] messages) {
           // This method shouldn't be called on liveCache, but we will provide the implementation
for it anyway
           for (PagedMessage msg : messages) {
              addLiveMessage(msg);
           }
        }
     
        @Override
    -   public synchronized PagedMessage getMessage(int messageNumber) {
    -      if (messageNumber < messages.size()) {
    -         return messages.get(messageNumber);
    -      } else {
    +   public PagedMessage getMessage(int messageNumber) {
    +      if (messageNumber < 0) {
              return null;
           }
    +      //it allow to perform less cache invalidations vs producerIndex if there are bursts
of appends
    +      long size = lastSeenProducerIndex;
    +      if (messageNumber >= size) {
    +         while ((size = producerIndex) == RESIZING) {
    +            Thread.yield();
    +         }
    +         //it is a message over the current size?
    +         if (messageNumber >= size) {
    --- End diff --
    
    I know but in the original version it was handled in that way and it covers 2 case: the
collection is null and the collection hasn't enough element


---

Mime
View raw message