You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "ifesdjeen (via GitHub)" <gi...@apache.org> on 2025/10/28 12:37:52 UTC

Re: [PR] Fixes 250919 [cassandra-accord]

ifesdjeen commented on code in PR #255:
URL: https://github.com/apache/cassandra-accord/pull/255#discussion_r2469368448


##########
accord-core/src/main/java/accord/impl/DefaultLocalListeners.java:
##########
@@ -530,4 +551,177 @@ public void clear()
             }
         });
     }
+
+    @Override
+    public Iterable<TxnId> txnsWaitingOn(SaveStatus saveStatus)

Review Comment:
   nit: unclear if intentional or not, but this param is unused



##########
accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLog.java:
##########
@@ -552,38 +553,52 @@ public void accept(@Nullable SafeCommandStore safeStore)
         }
     }
 
+    private int runBufferWaitingCount() { return runBufferWaitingEndIndex - runBufferWaitingIndex; }
+    private int runBufferHomeCount() { return runBufferHomeIndex - runBufferHomeLastIndex; }
+    private int runBufferTotalCount() { return runBufferWaitingCount() + runBufferHomeCount(); }
+
     private void addToRunBuffer(RunInvoker readyToRun)
     {
-        if (runBufferCount == runBuffer.length)
+        if (runBufferWaitingEndIndex == runBufferHomeLastIndex)
         {
-            int newCount = runBufferCount - runBufferIndex;
-            Object[] newBuffer = cachedAny().get(Math.max(8, newCount * 2));
+            int newSize = Math.max(8, 2 * runBufferTotalCount());
+            Object[] newBuffer;
+            if (newSize <= runBuffer.length) newBuffer = runBuffer;
+            else newBuffer = cachedAny().get(newSize);
             replaceRunBuffer(newBuffer);
         }
-        runBuffer[runBufferCount++] = readyToRun;
+        if (readyToRun.runKind == Waiting) runBuffer[runBufferWaitingEndIndex++] = readyToRun;
+        else runBuffer[--runBufferHomeLastIndex] = readyToRun;
     }
 
-    private void replaceRunBuffer(Object[] newBuffer)
+    private void maybeShrinkRunBuffer()
     {
-        Object[] prevBuffer = runBuffer;
-        int prevCount = runBufferCount;
-        int newCount = prevCount - runBufferIndex;
-        System.arraycopy(prevBuffer, runBufferIndex, newBuffer, 0, newCount);
-        runBuffer = newBuffer;
-        runBufferIndex = 0;
-        runBufferCount = newCount;
-        if (prevBuffer.length >= ArrayBuffers.MIN_BUFFER_SIZE)
-            cachedAny().forceDiscard(prevBuffer, prevCount);
+        if (runBuffer.length <= runBufferTotalCount() / 2 && runBuffer.length > 8)

Review Comment:
   did you mean an inverted statement here? 
   
   I am assuming run buffer total count is always smaller than its length, or?



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

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org