You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "belliottsmith (via GitHub)" <gi...@apache.org> on 2023/01/27 23:26:44 UTC

[GitHub] [cassandra-accord] belliottsmith commented on a diff in pull request #28: CASSANDRA-18203: CEP-15: (C*) Improve Burn Tests to include thread scheduling

belliottsmith commented on code in PR #28:
URL: https://github.com/apache/cassandra-accord/pull/28#discussion_r1089543532


##########
accord-core/src/test/java/accord/impl/basic/DelayedExecutorService.java:
##########
@@ -0,0 +1,80 @@
+package accord.impl.basic;
+
+import org.apache.cassandra.concurrent.FutureTask;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.AbstractExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class DelayedExecutorService extends AbstractExecutorService
+{
+    private static final int THREAD_SCHEDULING_OVERHEAD_MILLIS = 5;
+
+    private final PendingQueue pending;
+    private final Random random;
+
+    public DelayedExecutorService(PendingQueue pending, Random random)
+    {
+        this.pending = pending;
+        this.random = random;
+    }
+
+    @Override
+    protected <T> Task<T> newTaskFor(Runnable runnable, T value) {
+        return newTaskFor(Executors.callable(runnable, value));
+    }
+
+    @Override
+    protected <T> Task<T> newTaskFor(Callable<T> callable) {
+        return new Task<>(callable);
+    }
+
+    private Task<?> newTaskFor(Runnable command) {
+        return command instanceof Task ? (Task<?>) command : newTaskFor(command, null);
+    }
+
+    @Override
+    public void execute(Runnable command) {
+        Task<?> task = newTaskFor(command);
+        int jitterMillis = THREAD_SCHEDULING_OVERHEAD_MILLIS + random.nextInt(1000);

Review Comment:
   On average 505ms of latency for scheduling seems a bit steep. Might be nice to copy some of the simulator's behaviour here if we could, so that there's some patterns. Probably it should average tens to hundreds of micros, though, with some larger periods.



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