From 36db89c255d02a33b8c179207506b464e6b70c53 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Thu, 1 Aug 2024 15:46:00 -0400 Subject: [PATCH 01/68] Fiber refactorings --- .../org/eclipse/rdf4j/workbench/commands/SummaryServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/SummaryServlet.java b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/SummaryServlet.java index fe50b00d616..82979a7254d 100644 --- a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/SummaryServlet.java +++ b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/SummaryServlet.java @@ -34,7 +34,7 @@ public class SummaryServlet extends TransformationServlet { - private final ExecutorService executorService = Executors.newCachedThreadPool(); + private final ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); private static final Logger LOGGER = LoggerFactory.getLogger(SummaryServlet.class); From bcbc3380b252e3d71eb9ab40290b5e153b0e1727 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:52:47 -0400 Subject: [PATCH 02/68] Update ShaclSail.java --- .../java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index f2b75e528ed..98175e68eb5 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,16 +252,7 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, - r -> { - Thread t = Executors.defaultThreadFactory().newThread(r); - // this thread pool does not need to stick around if the all other threads are done, because - // it is only used for SHACL validation and if all other threads have ended then there would - // be no thread to receive the validation results. - t.setDaemon(true); - t.setName("ShaclSail validation thread " + t.getId()); - return t; - })); + () -> Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("ShaclSail validation thread ", t.getId()).factory())) } void closeConnection() { From 4208e91f81c0cf65c8c33fcce5f989ab85dddfc2 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:02:32 -0400 Subject: [PATCH 03/68] Update ShaclSail.java --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 98175e68eb5..414bc754359 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,7 +252,7 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - () -> Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("ShaclSail validation thread ", t.getId()).factory())) + () -> Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("ShaclSail validation thread ", t.getId()).factory())); } void closeConnection() { From fb0c8b38a19ba1a5491ebe5426291d89510973c0 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:13:07 -0400 Subject: [PATCH 04/68] Update ShaclSail.java --- .../java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 414bc754359..5d0d150f458 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,7 +252,15 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - () -> Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("ShaclSail validation thread ", t.getId()).factory())); + () -> Executors.newThreadPerTaskExecutor(AVAILABLE_PROCESSORS, + r -> { + Thread t = Thread.ofVirtual().factory().newThread(r); + // this thread pool does not need to stick around if the all other threads are done, because + // it is only used for SHACL validation and if all other threads have ended then there would + // be no thread to receive the validation results. + t.setName("ShaclSail validation thread " + t.getId()); + return t; + })); } void closeConnection() { From dc3b580a74b77b5f63db68bfb038e41e0a1cb4ec Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:16:56 -0400 Subject: [PATCH 05/68] Update ShaclSail.java --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 5d0d150f458..c550bc6eeee 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,7 +252,7 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - () -> Executors.newThreadPerTaskExecutor(AVAILABLE_PROCESSORS, + () -> Executors.newThreadPerTaskExecutor( r -> { Thread t = Thread.ofVirtual().factory().newThread(r); // this thread pool does not need to stick around if the all other threads are done, because From 8d867f749f79ef0d2ea2afc8d73920d3e67fcefa Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:27:10 -0400 Subject: [PATCH 06/68] Update SharedHttpClientSessionManager.java --- .../http/client/SharedHttpClientSessionManager.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java index 43412f081f9..3d4afb02809 100644 --- a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java +++ b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java @@ -164,18 +164,7 @@ public long getRetryInterval() { *--------------*/ public SharedHttpClientSessionManager() { - final ThreadFactory backingThreadFactory = Executors.defaultThreadFactory(); - - ExecutorService threadPoolExecutor = Executors.newCachedThreadPool((Runnable runnable) -> { - Thread thread = backingThreadFactory.newThread(runnable); - thread.setName( - String.format("rdf4j-SharedHttpClientSessionManager-%d", threadCount.getAndIncrement())); - thread.setDaemon(true); - return thread; - }); - - Integer corePoolSize = Integer.getInteger(CORE_POOL_SIZE_PROPERTY, 1); - ((ThreadPoolExecutor) threadPoolExecutor).setCorePoolSize(corePoolSize); + ExecutorService threadPoolExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("rdf4j-SharedHttpClientSessionManager-", threadCount.getAndIncrement()).factory()); this.executor = threadPoolExecutor; } From f4c26db0f051e33169d3ec1e9d1a0c65db006d79 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:29:05 -0400 Subject: [PATCH 07/68] Update LmdbSailStore.java --- .../main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java index 02e7d71bf5d..531711a122e 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java @@ -64,7 +64,7 @@ class LmdbSailStore implements SailStore { private final ValueStore valueStore; - private final ExecutorService tripleStoreExecutor = Executors.newCachedThreadPool(); + private final ExecutorService tripleStoreExecutor = Executors.newVirtualThreadPerTaskExecutor(); private final CircularBuffer opQueue = new CircularBuffer<>(1024); private volatile Throwable tripleStoreException; private final AtomicBoolean running = new AtomicBoolean(false); From 8c12ad44894be670bd71676bd88c2031c2abbf38 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Thu, 1 Aug 2024 20:42:51 -0400 Subject: [PATCH 08/68] Format --- .../rdf4j/http/client/SharedHttpClientSessionManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java index 3d4afb02809..2ca031527af 100644 --- a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java +++ b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/SharedHttpClientSessionManager.java @@ -164,7 +164,9 @@ public long getRetryInterval() { *--------------*/ public SharedHttpClientSessionManager() { - ExecutorService threadPoolExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("rdf4j-SharedHttpClientSessionManager-", threadCount.getAndIncrement()).factory()); + ExecutorService threadPoolExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual() + .name("rdf4j-SharedHttpClientSessionManager-", threadCount.getAndIncrement()) + .factory()); this.executor = threadPoolExecutor; } From 9b33fdde7bb205c31aa61da293c691aa59e5ec1b Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:54:04 -0400 Subject: [PATCH 09/68] Update SPARQLOperation.java --- .../eclipse/rdf4j/repository/sparql/query/SPARQLOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/query/SPARQLOperation.java b/core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/query/SPARQLOperation.java index f1e9b8ba114..fb134112375 100644 --- a/core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/query/SPARQLOperation.java +++ b/core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/query/SPARQLOperation.java @@ -35,7 +35,7 @@ @Deprecated public abstract class SPARQLOperation implements Operation { - private static final Executor executor = Executors.newCachedThreadPool(); + private static final Executor executor = Executors.newVirtualThreadPerTaskExecutor(); protected HttpClient client; From 2ac25caed23ec4197a9287304a411dbbfc238121 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:58:40 -0400 Subject: [PATCH 10/68] Update BaseLockManagerBenchmark.java --- .../concurrent/locks/benchmarks/BaseLockManagerBenchmark.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/api/src/test/java/org/eclipse/rdf4j/common/concurrent/locks/benchmarks/BaseLockManagerBenchmark.java b/core/sail/api/src/test/java/org/eclipse/rdf4j/common/concurrent/locks/benchmarks/BaseLockManagerBenchmark.java index cdae8228540..569be9dbdd8 100644 --- a/core/sail/api/src/test/java/org/eclipse/rdf4j/common/concurrent/locks/benchmarks/BaseLockManagerBenchmark.java +++ b/core/sail/api/src/test/java/org/eclipse/rdf4j/common/concurrent/locks/benchmarks/BaseLockManagerBenchmark.java @@ -33,7 +33,7 @@ public class BaseLockManagerBenchmark { public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ReadPrefReadWriteLockManager.class.getName()); root.setLevel(ch.qos.logback.classic.Level.ERROR); - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + executorService = Executors.newVirtualThreadPerTaskExecutor(); } @TearDown(Level.Trial) From 81dbe68f4918fe9e70a047e4fdd86bfe422f1b1d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:01:45 -0400 Subject: [PATCH 11/68] Update RepositoryPerformance.java --- .../rdf4j/federated/performance/RepositoryPerformance.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RepositoryPerformance.java b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RepositoryPerformance.java index 67d7ac1af82..e55f8617027 100644 --- a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RepositoryPerformance.java +++ b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RepositoryPerformance.java @@ -55,7 +55,7 @@ private static abstract class PerformanceBase { private static final int MAX_INSTANCES = Integer.MAX_VALUE; private static final int N_QUERIES = 100; - private final ExecutorService executor = Executors.newFixedThreadPool(30); + private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); private final IRI type; From 2994a2dc23dc724b058972b507d4c196d5410857 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:02:47 -0400 Subject: [PATCH 12/68] Update OverflowBenchmarkConcurrent.java --- .../sail/nativerdf/benchmark/OverflowBenchmarkConcurrent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/benchmark/OverflowBenchmarkConcurrent.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/benchmark/OverflowBenchmarkConcurrent.java index 277c6c498ec..558c257f1aa 100644 --- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/benchmark/OverflowBenchmarkConcurrent.java +++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/benchmark/OverflowBenchmarkConcurrent.java @@ -101,7 +101,7 @@ public void manyConcurrentTransactions() throws IOException { SailRepository sailRepository = new SailRepository(new NotifySailWrapper(new NotifySailWrapper( new NotifySailWrapper( new NotifySailWrapper(new NotifySailWrapper(new NativeStore(temporaryFolder))))))); - ExecutorService executorService = Executors.newFixedThreadPool(10); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { From 44abd82932c17a071902ffc4d57d9dcc69b1a575 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:08:57 -0400 Subject: [PATCH 13/68] Update OverflowBenchmarkConcurrent.java --- .../rdf4j/sail/lmdb/benchmark/OverflowBenchmarkConcurrent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/OverflowBenchmarkConcurrent.java b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/OverflowBenchmarkConcurrent.java index eef34f93d1c..b4563e141a8 100644 --- a/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/OverflowBenchmarkConcurrent.java +++ b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/OverflowBenchmarkConcurrent.java @@ -109,7 +109,7 @@ public void manyConcurrentTransactions() throws IOException { SailRepository sailRepository = new SailRepository(new NotifySailWrapper(new NotifySailWrapper( new NotifySailWrapper( new NotifySailWrapper(new NotifySailWrapper(new LmdbStore(temporaryFolder))))))); - ExecutorService executorService = Executors.newFixedThreadPool(10); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { From 026f1d7a0769ad377dd9cc74e6fea7b39fdf2a2b Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:09:31 -0400 Subject: [PATCH 14/68] Update RemoteRepositoryTest.java --- .../rdf4j/federated/performance/RemoteRepositoryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RemoteRepositoryTest.java b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RemoteRepositoryTest.java index 1782e30d54a..3cec035b259 100644 --- a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RemoteRepositoryTest.java +++ b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/RemoteRepositoryTest.java @@ -40,7 +40,7 @@ public class RemoteRepositoryTest { */ public static void main(String[] args) throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(30); + ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); Repository repo = new HTTPRepository("http://10.212.10.29:8081/openrdf-sesame", "drugbank"); From a963c771ac5a325e089f60bb444678f808155899 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:10:40 -0400 Subject: [PATCH 15/68] Update BaseConcurrentBenchmark.java --- .../rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 06ab62708af..dfca939628d 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -42,7 +42,7 @@ public void setup() throws Exception { if (executorService != null) { executorService.shutdownNow(); } - executorService = Executors.newFixedThreadPool(8); + executorService = Executors.newVirtualThreadPerTaskExecutor(); } @TearDown(Level.Trial) From a0a1351684be2563c7edb698bedc2f464140251d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:14:26 -0400 Subject: [PATCH 16/68] Update SparqlRepositoryTest.java --- .../rdf4j/federated/performance/SparqlRepositoryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/SparqlRepositoryTest.java b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/SparqlRepositoryTest.java index 3f9ac1b0957..efbda858733 100644 --- a/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/SparqlRepositoryTest.java +++ b/tools/federation/src/test/java/org/eclipse/rdf4j/federated/performance/SparqlRepositoryTest.java @@ -29,7 +29,7 @@ public class SparqlRepositoryTest { public static void main(String[] args) throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(20); + ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); SPARQLRepository repo = new SPARQLRepository("http://dbpedia.org/sparql"); repo.init(); From 05e7756795658425e758e89aa7d273fd0e2386e1 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:39:03 -0400 Subject: [PATCH 17/68] Update ProtocolIT.java --- .../test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java index fd1ac4c346d..dfe2e4bba16 100644 --- a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java +++ b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java @@ -442,8 +442,7 @@ public void testConcurrentNamespaceUpdates() throws Exception { // "Test-NativeStore"); String repositoryLocation = TestServer.REPOSITORY_URL; - ExecutorService threadPool = Executors.newFixedThreadPool(20, - new ThreadFactoryBuilder().setNameFormat("rdf4j-protocoltest-%d").build()); + ExecutorService threadPool = Executors.newThreadPerTaskExecutor(new NamingThreadFactory("rdf4j-protocoltest-")); for (int count = 0; count < limitCount; count++) { final int number = count; From 63ceb4efcd106b8477ffd75bb1927241ca225f23 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:39:06 -0400 Subject: [PATCH 18/68] Update ControlledWorkerScheduler.java --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index f677ca46ea4..352f4333a60 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -12,9 +12,9 @@ import java.util.List; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import org.eclipse.rdf4j.common.iteration.CloseableIteration; @@ -118,9 +118,7 @@ public int getNumberOfTasks() { private ExecutorService createExecutorService() { - ThreadPoolExecutor executor = new ThreadPoolExecutor(nWorkers, nWorkers, 60L, TimeUnit.SECONDS, _taskQueue, - new NamingThreadFactory(name)); - executor.allowCoreThreadTimeOut(true); + ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)) return executor; } From 4e0a445bf5d6f62f725ea2f989b7ea9087e21024 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:39:09 -0400 Subject: [PATCH 19/68] Update FederationManager.java --- .../java/org/eclipse/rdf4j/federated/FederationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java index 263ace78bf0..234bb28567f 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java @@ -92,7 +92,7 @@ public FederationManager() { public void init(FedX federation, FederationContext federationContext) { this.federation = federation; this.federationContext = federationContext; - this.executor = Executors.newCachedThreadPool(new NamingThreadFactory("FedX Executor")); + this.executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory("FedX Executor")); updateFederationType(); reset(); From f65eb74191270718b4779fdc0eb061fa3243f5dd Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:39:13 -0400 Subject: [PATCH 20/68] Update NamingThreadFactory.java --- .../federated/evaluation/concurrent/NamingThreadFactory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java index 2db262875a6..2d7cf1a508f 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java @@ -29,8 +29,7 @@ public NamingThreadFactory(String baseName) { @Override public Thread newThread(Runnable r) { - Thread t = Executors.defaultThreadFactory().newThread(r); - t.setName(baseName + "-" + nextThreadId.incrementAndGet()); + Thread t = Thread.ofVirtual().name(baseName + "-", nextThreadId.incrementAndGet()).unstarted(r); return t; } From 87fb81c2c99dd148957f729ae358c5ac52aceebf Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:44:52 -0400 Subject: [PATCH 21/68] Update ControlledWorkerScheduler.java --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index 352f4333a60..1a1f3639034 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -118,7 +118,7 @@ public int getNumberOfTasks() { private ExecutorService createExecutorService() { - ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)) + ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)); return executor; } From 2f9ebe30a33f8dd15520f42955132732f9b2aa8e Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:49:05 -0400 Subject: [PATCH 22/68] Update ProtocolIT.java --- .../src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java index dfe2e4bba16..5bf43caa8fa 100644 --- a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java +++ b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java @@ -45,6 +45,7 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.eclipse.rdf4j.common.io.IOUtil; +org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; import org.eclipse.rdf4j.http.protocol.Protocol; import org.eclipse.rdf4j.model.Namespace; import org.eclipse.rdf4j.model.ValueFactory; @@ -61,7 +62,6 @@ import org.junit.jupiter.api.Test; import com.google.common.collect.Sets; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.opencsv.CSVReader; public class ProtocolIT { From d8797ca4f0bfe0b9940a5154d89abc1ee3ae5c0e Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Fri, 2 Aug 2024 09:53:52 -0400 Subject: [PATCH 23/68] Format --- .../test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java index 5bf43caa8fa..07b4cc16d56 100644 --- a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java +++ b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java @@ -44,8 +44,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; -import org.eclipse.rdf4j.common.io.IOUtil; -org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; +import org.eclipse.rdf4j.common.io.IOUtil;org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; import org.eclipse.rdf4j.http.protocol.Protocol; import org.eclipse.rdf4j.model.Namespace; import org.eclipse.rdf4j.model.ValueFactory; From de2fb259b56aa57f1fead1a189fe6fd0bb1d0a1d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:56:54 -0400 Subject: [PATCH 24/68] Update pr-verify.yml --- .github/workflows/pr-verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index 087a30d4e1a..055505d746d 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -79,7 +79,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 12 + java-version: 21 - name: Cache local Maven repository uses: actions/cache@v2 with: From d87de117b65a56c72611cc39e6f33dab4ad2b790 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Fri, 2 Aug 2024 09:58:58 -0400 Subject: [PATCH 25/68] Revert "Update pr-verify.yml" This reverts commit de2fb259b56aa57f1fead1a189fe6fd0bb1d0a1d. --- .github/workflows/pr-verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index 055505d746d..087a30d4e1a 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -79,7 +79,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 21 + java-version: 12 - name: Cache local Maven repository uses: actions/cache@v2 with: From f95fb7a28797c2129088d1e6bd2250c7a023b89e Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:09:11 -0400 Subject: [PATCH 26/68] Update ProtocolIT.java --- .../test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java index 07b4cc16d56..14c0ca9dfb4 100644 --- a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java +++ b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java @@ -44,7 +44,8 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; -import org.eclipse.rdf4j.common.io.IOUtil;org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; +import org.eclipse.rdf4j.common.io.IOUtil; +import org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; import org.eclipse.rdf4j.http.protocol.Protocol; import org.eclipse.rdf4j.model.Namespace; import org.eclipse.rdf4j.model.ValueFactory; From 2bd6e75c9e44fd05108318eff6e81af9f31f36cd Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:16:36 -0400 Subject: [PATCH 27/68] Update ControlledWorkerScheduler.java --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index 1a1f3639034..7715963aab5 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -12,9 +12,9 @@ import java.util.List; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import org.eclipse.rdf4j.common.iteration.CloseableIteration; @@ -117,8 +117,10 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { - - ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)); + // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + ThreadPoolExecutor executor = new ThreadPoolExecutor(nWorkers, nWorkers, 60L, TimeUnit.SECONDS, _taskQueue, + new NamingThreadFactory(name)); + executor.allowCoreThreadTimeOut(true); return executor; } From 1ca38e2d6317c62eb0668cb7f490899f8c990ac1 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:16:40 -0400 Subject: [PATCH 28/68] Update NamingThreadFactory.java --- .../federated/evaluation/concurrent/NamingThreadFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java index 2d7cf1a508f..f3a53ded28a 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java @@ -29,7 +29,9 @@ public NamingThreadFactory(String baseName) { @Override public Thread newThread(Runnable r) { - Thread t = Thread.ofVirtual().name(baseName + "-", nextThreadId.incrementAndGet()).unstarted(r); + // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + Thread t = Executors.defaultThreadFactory().newThread(r); + t.setName(baseName + "-" + nextThreadId.incrementAndGet()); return t; } From 3b5dcd4798012d88097426d9c70c3ef8e02ab88c Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:16:43 -0400 Subject: [PATCH 29/68] Update FederationManager.java --- .../java/org/eclipse/rdf4j/federated/FederationManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java index 234bb28567f..8964c313bd9 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java @@ -92,7 +92,8 @@ public FederationManager() { public void init(FedX federation, FederationContext federationContext) { this.federation = federation; this.federationContext = federationContext; - this.executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory("FedX Executor")); + // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + this.executor = Executors.newCachedThreadPool(new NamingThreadFactory("FedX Executor")); updateFederationType(); reset(); From b61be8bc7df68d677554727682ab673ac05e43a3 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Mon, 5 Aug 2024 12:33:03 -0400 Subject: [PATCH 30/68] Formatting --- .../java/org/eclipse/rdf4j/federated/FederationManager.java | 3 ++- .../evaluation/concurrent/ControlledWorkerScheduler.java | 3 ++- .../federated/evaluation/concurrent/NamingThreadFactory.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java index 8964c313bd9..6da89041e80 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java @@ -92,7 +92,8 @@ public FederationManager() { public void init(FedX federation, FederationContext federationContext) { this.federation = federation; this.federationContext = federationContext; - // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + // Refactoring this causes ServicesTest to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) this.executor = Executors.newCachedThreadPool(new NamingThreadFactory("FedX Executor")); updateFederationType(); diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index 7715963aab5..ae8cdef765b 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -117,7 +117,8 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { - // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + // Refactoring this causes ServicesTest to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) ThreadPoolExecutor executor = new ThreadPoolExecutor(nWorkers, nWorkers, 60L, TimeUnit.SECONDS, _taskQueue, new NamingThreadFactory(name)); executor.allowCoreThreadTimeOut(true); diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java index f3a53ded28a..c058c1a1ee6 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java @@ -29,7 +29,8 @@ public NamingThreadFactory(String baseName) { @Override public Thread newThread(Runnable r) { - // Refactoring this causes ServicesTest to hang forever (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) + // Refactoring this causes ServicesTest to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) Thread t = Executors.defaultThreadFactory().newThread(r); t.setName(baseName + "-" + nextThreadId.incrementAndGet()); return t; From 0458da45265599feff44903a9bd55877411b7866 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Sun, 25 Aug 2024 17:55:53 -0400 Subject: [PATCH 31/68] Refactorings for additional JMH tests --- .../federation/RepositoryFederatedServiceIntegrationTest.java | 2 +- .../query/algebra/evaluation/impl/MinimalContextNowTest.java | 2 +- .../java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java | 2 +- .../rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java | 4 ++-- .../rdf4j/sail/memory/model/MemStatementListTestIT.java | 4 ++-- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java index 763d3c2a6d2..9b92fd657e3 100644 --- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java +++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java @@ -295,7 +295,7 @@ public void test9_connectionHandling() throws Exception { .map(value -> vf.createStatement(iri("s1"), RDFS.LABEL, value)) .collect(Collectors.toList())); - ExecutorService executor = Executors.newFixedThreadPool(5); + ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 5; i++) { executor.submit(() -> { diff --git a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java index a4d5af4ebb5..99102c89d61 100644 --- a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java +++ b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java @@ -49,7 +49,7 @@ public void testConcurrentAccessToNow() throws ExecutionException, InterruptedEx int numberOfIterations = 100; int numberOfThreads = 10; - ExecutorService executorService = Executors.newCachedThreadPool(); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < numberOfIterations; i++) { diff --git a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java index c1c64931f40..0d3b6312d58 100644 --- a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java +++ b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java @@ -101,7 +101,7 @@ public void testConcurrentAutoInit() throws Exception { CountDownLatch latch = new CountDownLatch(count); for (int i = 0; i < count; i++) { - new Thread(new SailGetConnectionTask(subject, latch)).start(); + Thread.ofVirtual().start(new SailGetConnectionTask(subject, latch)); } if (!latch.await(30, TimeUnit.SECONDS)) { diff --git a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java index 1e09c30169e..6aee01eb74f 100644 --- a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java +++ b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java @@ -773,7 +773,7 @@ public void testMultithreadedAdd() throws InterruptedException { final CountDownLatch endLatch = new CountDownLatch(numThreads); final Set exceptions = ConcurrentHashMap.newKeySet(); for (int i = 0; i < numThreads; i++) { - new Thread(new Runnable() { + Thread.ofVirtual().start(new Runnable() { private final long iterationCount = 10 + Math.round(random.nextDouble() * 100); @@ -791,7 +791,7 @@ public void run() { endLatch.countDown(); } } - }).start(); + }); } startLatch.countDown(); endLatch.await(); diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java index c8594d67184..3f3fa9d278f 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java @@ -106,7 +106,7 @@ public void addMultipleThreads() throws ExecutionException, InterruptedException MemStatementList memStatementList = new MemStatementList(); - ExecutorService executorService = Executors.newCachedThreadPool(); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { List> collect = partition @@ -153,7 +153,7 @@ public void addMultipleThreadsAndCleanupThread() throws ExecutionException, Inte CountDownLatch countDownLatch = new CountDownLatch(1); - ExecutorService executorService = Executors.newCachedThreadPool(); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { Future cleanupFuture = executorService.submit(() -> { diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 89aea92cac9..2566d693ec4 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 3; i++) { @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + executorService = Executors.newVirtualThreadPerTaskExecutor(); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From fd7473db008686c1030f6b92cbdc389cfa71ce0d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:45:08 -0400 Subject: [PATCH 32/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 2566d693ec4..f4e69d5fed7 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -467,7 +467,9 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newVirtualThreadPerTaskExecutor(); + // Refactoring this causes testLotsOfValidationFailuresSerializable() to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10550384841/job/29226485226#step:7:5128) + executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 44a3603a89bbb1587818060826e41d72b1e0dea0 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:25:02 -0400 Subject: [PATCH 33/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index f4e69d5fed7..113a53936f6 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,8 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + // Does refactoring this cause problems?? + ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); try { for (int i = 0; i < 3; i++) { From b2506dbde10c49cdd8675a23c1e26fd075b18d4d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:49:24 -0400 Subject: [PATCH 34/68] Update ShaclSail.java --- .../main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index c550bc6eeee..7a5fe9779fb 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -251,13 +251,16 @@ public void setBaseSail(Sail baseSail) { */ @Experimental protected RevivableExecutorService getExecutorService() { + // Refactoring this causes MultithreadedTest.testLotsOfValidationFailuresSerializable() to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10550384841/job/29226485226#step:7:5128) return new RevivableExecutorService( - () -> Executors.newThreadPerTaskExecutor( + () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, r -> { - Thread t = Thread.ofVirtual().factory().newThread(r); + Thread t = Executors.defaultThreadFactory().newThread(r); // this thread pool does not need to stick around if the all other threads are done, because // it is only used for SHACL validation and if all other threads have ended then there would // be no thread to receive the validation results. + t.setDaemon(true); t.setName("ShaclSail validation thread " + t.getId()); return t; })); From a76b83ebb3e8b11b6325d42590aed3d0a8a7c8f1 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:49:29 -0400 Subject: [PATCH 35/68] Update MultithreadedTest.java --- .../org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 113a53936f6..2566d693ec4 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,8 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - // Does refactoring this cause problems?? - ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 3; i++) { @@ -468,9 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - // Refactoring this causes testLotsOfValidationFailuresSerializable() to hang forever - // (https://github.com/ponder-lab/rdf4j/actions/runs/10550384841/job/29226485226#step:7:5128) - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + executorService = Executors.newVirtualThreadPerTaskExecutor(); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 57957ef9cc519802cebd35e9283a8c5f7ddf163c Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Mon, 26 Aug 2024 14:34:35 -0400 Subject: [PATCH 36/68] Revert "Refactorings for additional JMH tests" This reverts commit 0458da45265599feff44903a9bd55877411b7866. --- .../RepositoryFederatedServiceIntegrationTest.java | 2 +- .../algebra/evaluation/impl/MinimalContextNowTest.java | 2 +- .../org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java | 2 +- .../rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java | 4 ++-- .../rdf4j/sail/memory/model/MemStatementListTestIT.java | 4 ++-- .../main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 7 ++----- .../org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 ++-- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java index 9b92fd657e3..763d3c2a6d2 100644 --- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java +++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java @@ -295,7 +295,7 @@ public void test9_connectionHandling() throws Exception { .map(value -> vf.createStatement(iri("s1"), RDFS.LABEL, value)) .collect(Collectors.toList())); - ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executor = Executors.newFixedThreadPool(5); try { for (int i = 0; i < 5; i++) { executor.submit(() -> { diff --git a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java index 99102c89d61..a4d5af4ebb5 100644 --- a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java +++ b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java @@ -49,7 +49,7 @@ public void testConcurrentAccessToNow() throws ExecutionException, InterruptedEx int numberOfIterations = 100; int numberOfThreads = 10; - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newCachedThreadPool(); try { for (int i = 0; i < numberOfIterations; i++) { diff --git a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java index 0d3b6312d58..c1c64931f40 100644 --- a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java +++ b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java @@ -101,7 +101,7 @@ public void testConcurrentAutoInit() throws Exception { CountDownLatch latch = new CountDownLatch(count); for (int i = 0; i < count; i++) { - Thread.ofVirtual().start(new SailGetConnectionTask(subject, latch)); + new Thread(new SailGetConnectionTask(subject, latch)).start(); } if (!latch.await(30, TimeUnit.SECONDS)) { diff --git a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java index 6aee01eb74f..1e09c30169e 100644 --- a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java +++ b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java @@ -773,7 +773,7 @@ public void testMultithreadedAdd() throws InterruptedException { final CountDownLatch endLatch = new CountDownLatch(numThreads); final Set exceptions = ConcurrentHashMap.newKeySet(); for (int i = 0; i < numThreads; i++) { - Thread.ofVirtual().start(new Runnable() { + new Thread(new Runnable() { private final long iterationCount = 10 + Math.round(random.nextDouble() * 100); @@ -791,7 +791,7 @@ public void run() { endLatch.countDown(); } } - }); + }).start(); } startLatch.countDown(); endLatch.await(); diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java index 3f3fa9d278f..c8594d67184 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java @@ -106,7 +106,7 @@ public void addMultipleThreads() throws ExecutionException, InterruptedException MemStatementList memStatementList = new MemStatementList(); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newCachedThreadPool(); try { List> collect = partition @@ -153,7 +153,7 @@ public void addMultipleThreadsAndCleanupThread() throws ExecutionException, Inte CountDownLatch countDownLatch = new CountDownLatch(1); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newCachedThreadPool(); try { Future cleanupFuture = executorService.submit(() -> { diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 7a5fe9779fb..c550bc6eeee 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -251,16 +251,13 @@ public void setBaseSail(Sail baseSail) { */ @Experimental protected RevivableExecutorService getExecutorService() { - // Refactoring this causes MultithreadedTest.testLotsOfValidationFailuresSerializable() to hang forever - // (https://github.com/ponder-lab/rdf4j/actions/runs/10550384841/job/29226485226#step:7:5128) return new RevivableExecutorService( - () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, + () -> Executors.newThreadPerTaskExecutor( r -> { - Thread t = Executors.defaultThreadFactory().newThread(r); + Thread t = Thread.ofVirtual().factory().newThread(r); // this thread pool does not need to stick around if the all other threads are done, because // it is only used for SHACL validation and if all other threads have ended then there would // be no thread to receive the validation results. - t.setDaemon(true); t.setName("ShaclSail validation thread " + t.getId()); return t; })); diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 2566d693ec4..89aea92cac9 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); try { for (int i = 0; i < 3; i++) { @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newVirtualThreadPerTaskExecutor(); + executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 502354f5747ba3d1791037b1c754703b6e67f92c Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:30:33 -0400 Subject: [PATCH 37/68] Update RepositoryFederatedServiceIntegrationTest.java --- .../federation/RepositoryFederatedServiceIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java index 763d3c2a6d2..9b92fd657e3 100644 --- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java +++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java @@ -295,7 +295,7 @@ public void test9_connectionHandling() throws Exception { .map(value -> vf.createStatement(iri("s1"), RDFS.LABEL, value)) .collect(Collectors.toList())); - ExecutorService executor = Executors.newFixedThreadPool(5); + ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 5; i++) { executor.submit(() -> { From 73fe77e58fbd9d0bd4365bafdef98e7d2ce72a48 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:54:55 -0400 Subject: [PATCH 38/68] Update ShaclSail.java --- .../main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index c550bc6eeee..f1ebe143ced 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,9 +252,10 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - () -> Executors.newThreadPerTaskExecutor( + // Does refactoring this cause tests to hang? + () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, r -> { - Thread t = Thread.ofVirtual().factory().newThread(r); + Thread t = Executors.defaultThreadFactory().newThread(r); // this thread pool does not need to stick around if the all other threads are done, because // it is only used for SHACL validation and if all other threads have ended then there would // be no thread to receive the validation results. From fc7d36ad3f47c05667db032c2e4f8ca81274b3dc Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:55:21 -0400 Subject: [PATCH 39/68] Update ShaclSail.java --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index f1ebe143ced..061f233ebfe 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -259,6 +259,7 @@ protected RevivableExecutorService getExecutorService() { // this thread pool does not need to stick around if the all other threads are done, because // it is only used for SHACL validation and if all other threads have ended then there would // be no thread to receive the validation results. + t.setDaemon(true); t.setName("ShaclSail validation thread " + t.getId()); return t; })); From 50cc7a22533ae6255ad6666b246f8ad3024f9e9f Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:13:24 -0400 Subject: [PATCH 40/68] Update MinimalContextNowTest.java --- .../query/algebra/evaluation/impl/MinimalContextNowTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java index a4d5af4ebb5..99102c89d61 100644 --- a/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java +++ b/core/queryalgebra/evaluation/src/test/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/MinimalContextNowTest.java @@ -49,7 +49,7 @@ public void testConcurrentAccessToNow() throws ExecutionException, InterruptedEx int numberOfIterations = 100; int numberOfThreads = 10; - ExecutorService executorService = Executors.newCachedThreadPool(); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < numberOfIterations; i++) { From e5c8414dd075c20dfcc3167e6029300bb23c5ad1 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:13:35 -0400 Subject: [PATCH 41/68] Update AbstractSailTest.java --- .../java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java index c1c64931f40..0d3b6312d58 100644 --- a/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java +++ b/core/sail/api/src/test/java/org/eclipse/rdf4j/sail/helpers/AbstractSailTest.java @@ -101,7 +101,7 @@ public void testConcurrentAutoInit() throws Exception { CountDownLatch latch = new CountDownLatch(count); for (int i = 0; i < count; i++) { - new Thread(new SailGetConnectionTask(subject, latch)).start(); + Thread.ofVirtual().start(new SailGetConnectionTask(subject, latch)); } if (!latch.await(30, TimeUnit.SECONDS)) { From d89a7ffcd6b03722637980e8d033b9141bee82ce Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:13:43 -0400 Subject: [PATCH 42/68] Update AbstractGenericLuceneTest.java --- .../rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java index 1e09c30169e..6aee01eb74f 100644 --- a/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java +++ b/core/sail/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/impl/AbstractGenericLuceneTest.java @@ -773,7 +773,7 @@ public void testMultithreadedAdd() throws InterruptedException { final CountDownLatch endLatch = new CountDownLatch(numThreads); final Set exceptions = ConcurrentHashMap.newKeySet(); for (int i = 0; i < numThreads; i++) { - new Thread(new Runnable() { + Thread.ofVirtual().start(new Runnable() { private final long iterationCount = 10 + Math.round(random.nextDouble() * 100); @@ -791,7 +791,7 @@ public void run() { endLatch.countDown(); } } - }).start(); + }); } startLatch.countDown(); endLatch.await(); From cb3a57b0cc118fe51b5b4a9f8b2fda8189ca1d7e Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:13:50 -0400 Subject: [PATCH 43/68] Update MemStatementListTestIT.java --- .../eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java index c8594d67184..5938b529867 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/model/MemStatementListTestIT.java @@ -106,7 +106,7 @@ public void addMultipleThreads() throws ExecutionException, InterruptedException MemStatementList memStatementList = new MemStatementList(); - ExecutorService executorService = Executors.newCachedThreadPool(); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { List> collect = partition From 92bedefee0c791903f6ddc9ea33ce751990ab37f Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:08:32 -0400 Subject: [PATCH 44/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 89aea92cac9..2566d693ec4 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 3; i++) { @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + executorService = Executors.newVirtualThreadPerTaskExecutor(); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 54f938dd6cf4f2183cd57b7b887dd9ddbc0bb9c2 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Mon, 26 Aug 2024 17:25:33 -0400 Subject: [PATCH 45/68] Revert "Update MultithreadedTest.java" This reverts commit 92bedefee0c791903f6ddc9ea33ce751990ab37f. --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 2566d693ec4..89aea92cac9 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); try { for (int i = 0; i < 3; i++) { @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newVirtualThreadPerTaskExecutor(); + executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From f9986e6841d8d73a0cea7a87d9f3fa321ddcf59b Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:28:27 -0400 Subject: [PATCH 46/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 89aea92cac9..3e6c09d046d 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); try { for (int i = 0; i < 3; i++) { From 505257d7b459a3d646c2cb4b595acc983d6026ce Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:20:32 -0400 Subject: [PATCH 47/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 3e6c09d046d..01d669aff6e 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); + ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); try { for (int i = 0; i < 3; i++) { @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + executorService = Executors.newVirtualThreadPerTaskExecutor(); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From bd70621e0c6e51daee3d2db451222fd8fc817434 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:31:54 -0400 Subject: [PATCH 48/68] Update MultithreadedTest.java --- .../org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 01d669aff6e..d2fca52c22a 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,6 +223,8 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); + // Refactoring this causes tests to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10567565368/job/29276778845) ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); try { @@ -467,7 +469,9 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - executorService = Executors.newVirtualThreadPerTaskExecutor(); + // Refactoring this causes tests to hang forever + (https://github.com/ponder-lab/rdf4j/actions/runs/10568156440/job/29278593171) + executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 2319564e3c40418a38b5bc74f0779d63a5dd54f9 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:33:21 -0400 Subject: [PATCH 49/68] Update ShaclSail.java --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 061f233ebfe..7e9269c6bbd 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,7 +252,8 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - // Does refactoring this cause tests to hang? + // Refactoring this causes tests to hang forever + // (https://github.com/ponder-lab/rdf4j/actions/runs/10561618648/job/29257740868) () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, r -> { Thread t = Executors.defaultThreadFactory().newThread(r); From 1c248e85bd3024de8ecd79f6cae43e6fd5c8e421 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:37:38 -0400 Subject: [PATCH 50/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index d2fca52c22a..6639737cf1d 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -470,7 +470,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.start(); // Refactoring this causes tests to hang forever - (https://github.com/ponder-lab/rdf4j/actions/runs/10568156440/job/29278593171) + // (https://github.com/ponder-lab/rdf4j/actions/runs/10568156440/job/29278593171) executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); Utils.loadShapeData(repository, "complexBenchmark/shacl.trig"); From 4fffdfcdaa63932cc1b39b7c77781553f5dc0937 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Mon, 26 Aug 2024 22:02:55 -0400 Subject: [PATCH 51/68] Update ProtocolIT.java --- .../test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java index 14c0ca9dfb4..fd1ac4c346d 100644 --- a/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java +++ b/tools/server/src/test/java/org/eclipse/rdf4j/http/server/ProtocolIT.java @@ -45,7 +45,6 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.eclipse.rdf4j.common.io.IOUtil; -import org.eclipse.rdf4j.federated.evaluation.concurrent.NamingThreadFactory; import org.eclipse.rdf4j.http.protocol.Protocol; import org.eclipse.rdf4j.model.Namespace; import org.eclipse.rdf4j.model.ValueFactory; @@ -62,6 +61,7 @@ import org.junit.jupiter.api.Test; import com.google.common.collect.Sets; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.opencsv.CSVReader; public class ProtocolIT { @@ -442,7 +442,8 @@ public void testConcurrentNamespaceUpdates() throws Exception { // "Test-NativeStore"); String repositoryLocation = TestServer.REPOSITORY_URL; - ExecutorService threadPool = Executors.newThreadPerTaskExecutor(new NamingThreadFactory("rdf4j-protocoltest-")); + ExecutorService threadPool = Executors.newFixedThreadPool(20, + new ThreadFactoryBuilder().setNameFormat("rdf4j-protocoltest-%d").build()); for (int count = 0; count < limitCount; count++) { final int number = count; From ac834fbe476e5936bb5e12ff399d0d27e5423846 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Tue, 3 Dec 2024 16:13:58 -0500 Subject: [PATCH 52/68] Use semaphore to guard submit --- .../benchmark/BaseConcurrentBenchmark.java | 25 +++- .../BaseConcurrentBenchmark.java.save | 141 ++++++++++++++++++ 2 files changed, 163 insertions(+), 3 deletions(-) create mode 100644 core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index dfca939628d..28a1284f9e0 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -15,6 +15,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.Semaphore; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -32,6 +33,7 @@ public class BaseConcurrentBenchmark { Repository repository; private ExecutorService executorService; + private Semaphore semaphore; static InputStream getResourceAsStream(String filename) { return BaseConcurrentBenchmark.class.getClassLoader().getResourceAsStream(filename); @@ -43,6 +45,7 @@ public void setup() throws Exception { executorService.shutdownNow(); } executorService = Executors.newVirtualThreadPerTaskExecutor(); + semaphore = new Semaphore(8); } @TearDown(Level.Trial) @@ -61,8 +64,13 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { for (int i = 0; i < threadCount; i++) { executorService.submit(() -> { try { - latch.await(); - runnable.run(); + semaphore.acquire(); + try { + latch.await(); + runnable.run(); + } finally { + semaphore.release(); + } } catch (InterruptedException e) { e.printStackTrace(); } finally { @@ -77,7 +85,18 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } Future submit(Runnable runnable) { - return executorService.submit(runnable); + return executorService.submit(() -> { + try { + semaphore.acquire(); + try { + runnable.run(); + } finally { + semaphore.release(); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); } Runnable getRunnable(CountDownLatch startSignal, RepositoryConnection connection, diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save new file mode 100644 index 00000000000..fad59516d3e --- /dev/null +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2022 Eclipse RDF4J contributors. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Distribution License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + *******************************************************************************/ +package org.eclipse.rdf4j.sail.memory.benchmark; + +import java.io.InputStream; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +import org.eclipse.rdf4j.common.transaction.IsolationLevel; +import org.eclipse.rdf4j.repository.Repository; +import org.eclipse.rdf4j.repository.RepositoryConnection; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; + +@State(Scope.Benchmark) +public class BaseConcurrentBenchmark { + + Repository repository; + private ExecutorService executorService; + + static InputStream getResourceAsStream(String filename) { + return BaseConcurrentBenchmark.class.getClassLoader().getResourceAsStream(filename); + } + + @Setup(Level.Trial) + public void setup() throws Exception { + if (executorService != null) { + executorService.shutdownNow(); + } + executorService = Executors.new + } + + @TearDown(Level.Trial) + public void tearDown() throws Exception { + if (executorService != null) { + executorService.shutdownNow(); + executorService = null; + } + } + + void threads(int threadCount, Runnable runnable) throws InterruptedException { + + CountDownLatch latch = new CountDownLatch(1); + CountDownLatch latchDone = new CountDownLatch(threadCount); + + for (int i = 0; i < threadCount; i++) { + executorService.submit(() -> { + try { + latch.await(); + runnable.run(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + latchDone.countDown(); + } + }); + } + + latch.countDown(); + latchDone.await(); + + } + + Future submit(Runnable runnable) { + return executorService.submit(runnable); + } + + Runnable getRunnable(CountDownLatch startSignal, RepositoryConnection connection, + IsolationLevel isolationLevel, Consumer workload) { + + return () -> { + try { + startSignal.await(); + } catch (InterruptedException e) { + throw new IllegalStateException(); + } + RepositoryConnection localConnection = connection; + try { + if (localConnection == null) { + localConnection = repository.getConnection(); + } + + if (isolationLevel == null) { + localConnection.begin(); + } else { + localConnection.begin(isolationLevel); + } + workload.accept(localConnection); + localConnection.commit(); + + } finally { + if (connection == null) { + assert localConnection != null; + localConnection.close(); + } + } + }; + } + + Runnable getRunnable(CountDownLatch startSignal, T inputData, + Consumer workload) { + + return () -> { + try { + startSignal.await(); + } catch (InterruptedException e) { + throw new IllegalStateException(); + } + workload.accept(inputData); + }; + } + + Runnable getRunnable(CountDownLatch startSignal, T inputData1, + S inputData2, BiConsumer workload) { + + return () -> { + try { + startSignal.await(); + } catch (InterruptedException e) { + throw new IllegalStateException(); + } + workload.accept(inputData1, inputData2); + }; + } + +} From ffe1cf3ca370348e7d1ebd211e88d2b5eb1cdd01 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:27:08 -0500 Subject: [PATCH 53/68] Delete core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save --- .../BaseConcurrentBenchmark.java.save | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100644 core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save deleted file mode 100644 index fad59516d3e..00000000000 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java.save +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Eclipse RDF4J contributors. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Distribution License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - *******************************************************************************/ -package org.eclipse.rdf4j.sail.memory.benchmark; - -import java.io.InputStream; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - -import org.eclipse.rdf4j.common.transaction.IsolationLevel; -import org.eclipse.rdf4j.repository.Repository; -import org.eclipse.rdf4j.repository.RepositoryConnection; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; - -@State(Scope.Benchmark) -public class BaseConcurrentBenchmark { - - Repository repository; - private ExecutorService executorService; - - static InputStream getResourceAsStream(String filename) { - return BaseConcurrentBenchmark.class.getClassLoader().getResourceAsStream(filename); - } - - @Setup(Level.Trial) - public void setup() throws Exception { - if (executorService != null) { - executorService.shutdownNow(); - } - executorService = Executors.new - } - - @TearDown(Level.Trial) - public void tearDown() throws Exception { - if (executorService != null) { - executorService.shutdownNow(); - executorService = null; - } - } - - void threads(int threadCount, Runnable runnable) throws InterruptedException { - - CountDownLatch latch = new CountDownLatch(1); - CountDownLatch latchDone = new CountDownLatch(threadCount); - - for (int i = 0; i < threadCount; i++) { - executorService.submit(() -> { - try { - latch.await(); - runnable.run(); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - latchDone.countDown(); - } - }); - } - - latch.countDown(); - latchDone.await(); - - } - - Future submit(Runnable runnable) { - return executorService.submit(runnable); - } - - Runnable getRunnable(CountDownLatch startSignal, RepositoryConnection connection, - IsolationLevel isolationLevel, Consumer workload) { - - return () -> { - try { - startSignal.await(); - } catch (InterruptedException e) { - throw new IllegalStateException(); - } - RepositoryConnection localConnection = connection; - try { - if (localConnection == null) { - localConnection = repository.getConnection(); - } - - if (isolationLevel == null) { - localConnection.begin(); - } else { - localConnection.begin(isolationLevel); - } - workload.accept(localConnection); - localConnection.commit(); - - } finally { - if (connection == null) { - assert localConnection != null; - localConnection.close(); - } - } - }; - } - - Runnable getRunnable(CountDownLatch startSignal, T inputData, - Consumer workload) { - - return () -> { - try { - startSignal.await(); - } catch (InterruptedException e) { - throw new IllegalStateException(); - } - workload.accept(inputData); - }; - } - - Runnable getRunnable(CountDownLatch startSignal, T inputData1, - S inputData2, BiConsumer workload) { - - return () -> { - try { - startSignal.await(); - } catch (InterruptedException e) { - throw new IllegalStateException(); - } - workload.accept(inputData1, inputData2); - }; - } - -} From c4e490e66b812c5810bced109e749289faacd650 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:15:44 -0500 Subject: [PATCH 54/68] Update ShaclSail.java --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 7e9269c6bbd..29b8562164c 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -252,7 +252,9 @@ public void setBaseSail(Sail baseSail) { @Experimental protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( - // Refactoring this causes tests to hang forever + // Refactoring the below to Executors.newThreadPerTaskExecutor(r -> { + // Thread t = Thread.ofVirtual().factory().newThread(r); + // causes tests to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10561618648/job/29257740868) () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, r -> { From 34553178af27c652345cc75dc3718da16d857b95 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:19:14 -0500 Subject: [PATCH 55/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 6639737cf1d..0dbf22cad91 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -223,7 +223,7 @@ private void parallelTest(List> list, IsolationLevels isolatio Random r = new Random(52465534); - // Refactoring this causes tests to hang forever + // Refactoring this to Executors.newVirtualThreadPerTaskExecutor() causes tests to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10567565368/job/29276778845) ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); From 811c7680c4b47c477879464ab643aa6b1f1469a8 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:20:45 -0500 Subject: [PATCH 56/68] Update MultithreadedTest.java --- .../java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java index 0dbf22cad91..8316cd3d00a 100644 --- a/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java +++ b/core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/MultithreadedTest.java @@ -469,7 +469,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel deadlockDetectionThread.setDaemon(true); deadlockDetectionThread.start(); - // Refactoring this causes tests to hang forever + // Refactoring this to Executors.newVirtualThreadPerTaskExecutor() causes tests to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10568156440/job/29278593171) executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); From cc6333942ccb562543f25d6ab24d9ae8e353abad Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:29:21 -0500 Subject: [PATCH 57/68] Update FederationManager.java --- .../java/org/eclipse/rdf4j/federated/FederationManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java index 6da89041e80..b2e25919efd 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/FederationManager.java @@ -92,7 +92,8 @@ public FederationManager() { public void init(FedX federation, FederationContext federationContext) { this.federation = federation; this.federationContext = federationContext; - // Refactoring this causes ServicesTest to hang forever + // Refactoring this to Executors.newThreadPerTaskExecutor(new NamingThreadFactory("FedX Executor")); + // and refactoring NamingThreadFactory to use virtual threads causes ServicesTest to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) this.executor = Executors.newCachedThreadPool(new NamingThreadFactory("FedX Executor")); From cc12250c9d6dc896300998e158e8055bfbf1431c Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:30:14 -0500 Subject: [PATCH 58/68] Update ControlledWorkerScheduler.java --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index ae8cdef765b..c9b37942d3c 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -117,7 +117,8 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { - // Refactoring this causes ServicesTest to hang forever + // Refactoring this to ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)) + // and refactoring NamingThreadFactory to use virtual threads causes ServicesTest to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) ThreadPoolExecutor executor = new ThreadPoolExecutor(nWorkers, nWorkers, 60L, TimeUnit.SECONDS, _taskQueue, new NamingThreadFactory(name)); From f39553a711a1c7f6d15a4cc90d40f5bf70fda88a Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:30:48 -0500 Subject: [PATCH 59/68] Update NamingThreadFactory.java --- .../federated/evaluation/concurrent/NamingThreadFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java index c058c1a1ee6..38038a7e4da 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java @@ -29,7 +29,8 @@ public NamingThreadFactory(String baseName) { @Override public Thread newThread(Runnable r) { - // Refactoring this causes ServicesTest to hang forever + // Refactoring this to Thread t = Thread.ofVirtual().name(baseName + "-", nextThreadId.incrementAndGet()).unstarted(r); + // causes ServicesTest to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) Thread t = Executors.defaultThreadFactory().newThread(r); t.setName(baseName + "-" + nextThreadId.incrementAndGet()); From 1487328559143905524135e5541b7e08e04b3a1e Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Wed, 4 Dec 2024 11:00:13 -0500 Subject: [PATCH 60/68] Formatting --- .../src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java index 29b8562164c..c6bda70ad08 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSail.java @@ -253,7 +253,7 @@ public void setBaseSail(Sail baseSail) { protected RevivableExecutorService getExecutorService() { return new RevivableExecutorService( // Refactoring the below to Executors.newThreadPerTaskExecutor(r -> { - // Thread t = Thread.ofVirtual().factory().newThread(r); + // Thread t = Thread.ofVirtual().factory().newThread(r); // causes tests to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10561618648/job/29257740868) () -> Executors.newFixedThreadPool(AVAILABLE_PROCESSORS, From 620b83b2d70eca37ef3ed6b238577fcf3ae91ee0 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Wed, 4 Dec 2024 13:00:25 -0500 Subject: [PATCH 61/68] More formatting --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 3 ++- .../federated/evaluation/concurrent/NamingThreadFactory.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index c9b37942d3c..372c5b16b5b 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -117,7 +117,8 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { - // Refactoring this to ExecutorService executor = Executors.newThreadPerTaskExecutor(new NamingThreadFactory(name)) + // Refactoring this to ExecutorService executor = Executors.newThreadPerTaskExecutor(new + // NamingThreadFactory(name)) // and refactoring NamingThreadFactory to use virtual threads causes ServicesTest to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) ThreadPoolExecutor executor = new ThreadPoolExecutor(nWorkers, nWorkers, 60L, TimeUnit.SECONDS, _taskQueue, diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java index 38038a7e4da..05745afee71 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/NamingThreadFactory.java @@ -29,7 +29,8 @@ public NamingThreadFactory(String baseName) { @Override public Thread newThread(Runnable r) { - // Refactoring this to Thread t = Thread.ofVirtual().name(baseName + "-", nextThreadId.incrementAndGet()).unstarted(r); + // Refactoring this to Thread t = Thread.ofVirtual().name(baseName + "-", + // nextThreadId.incrementAndGet()).unstarted(r); // causes ServicesTest to hang forever // (https://github.com/ponder-lab/rdf4j/actions/runs/10239404923/job/28324948852?pr=2) Thread t = Executors.defaultThreadFactory().newThread(r); From ab36f176022d8381d3b679fa3ab0de0fbe5493e4 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:11:02 -0500 Subject: [PATCH 62/68] Update BaseConcurrentBenchmark.java --- .../rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 28a1284f9e0..87b226d2c58 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -73,6 +73,7 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } } catch (InterruptedException e) { e.printStackTrace(); + throw e; } finally { latchDone.countDown(); } @@ -84,7 +85,7 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } - Future submit(Runnable runnable) { + Future submit(Runnable runnable) throws InterruptedException { return executorService.submit(() -> { try { semaphore.acquire(); @@ -95,6 +96,7 @@ Future submit(Runnable runnable) { } } catch (InterruptedException e) { e.printStackTrace(); + throw e; } }); } From bae704fdaa96318b8b63a0b32508cbb25c7d4bb8 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Fri, 6 Dec 2024 11:13:51 -0500 Subject: [PATCH 63/68] Revert "Update BaseConcurrentBenchmark.java" This reverts commit ab36f176022d8381d3b679fa3ab0de0fbe5493e4. --- .../rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 87b226d2c58..28a1284f9e0 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -73,7 +73,6 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } } catch (InterruptedException e) { e.printStackTrace(); - throw e; } finally { latchDone.countDown(); } @@ -85,7 +84,7 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } - Future submit(Runnable runnable) throws InterruptedException { + Future submit(Runnable runnable) { return executorService.submit(() -> { try { semaphore.acquire(); @@ -96,7 +95,6 @@ Future submit(Runnable runnable) throws InterruptedException { } } catch (InterruptedException e) { e.printStackTrace(); - throw e; } }); } From 295b83612a8e25795549c21b3a462c8bdc4f262a Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Fri, 6 Dec 2024 11:54:57 -0500 Subject: [PATCH 64/68] Fix positioning of semaphore acquisition/guarding --- .../benchmark/BaseConcurrentBenchmark.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 28a1284f9e0..11a4b3029a8 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -11,6 +11,7 @@ package org.eclipse.rdf4j.sail.memory.benchmark; import java.io.InputStream; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -62,21 +63,22 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { CountDownLatch latchDone = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; i++) { - executorService.submit(() -> { - try { - semaphore.acquire(); + semaphore.acquire(); + try { + executorService.submit(() -> { try { latch.await(); runnable.run(); + } catch (InterruptedException e) { + e.printStackTrace(); } finally { - semaphore.release(); + latchDone.countDown(); } - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - latchDone.countDown(); - } - }); + }); + } finally { + semaphore.release(); + } + } latch.countDown(); @@ -85,18 +87,15 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } Future submit(Runnable runnable) { - return executorService.submit(() -> { - try { - semaphore.acquire(); - try { - runnable.run(); - } finally { - semaphore.release(); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - }); + try { + semaphore.acquire(); + return executorService.submit(runnable); + } catch (InterruptedException e) { + e.printStackTrace(); + return CompletableFuture.completedFuture(null); + } finally { + semaphore.release(); + } } Runnable getRunnable(CountDownLatch startSignal, RepositoryConnection connection, @@ -157,4 +156,4 @@ Runnable getRunnable(CountDownLatch startSignal, T inputData1, }; } -} +} \ No newline at end of file From 707e905ce5ccffe0a87e1be7ffafec487db599fe Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Sat, 7 Dec 2024 16:59:41 -0500 Subject: [PATCH 65/68] Fix whitespace errors --- .../rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 11a4b3029a8..254a7158b67 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -78,7 +78,6 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } finally { semaphore.release(); } - } latch.countDown(); @@ -156,4 +155,4 @@ Runnable getRunnable(CountDownLatch startSignal, T inputData1, }; } -} \ No newline at end of file +} From 7fdeae2ddc5015005be87771e374d4b7653101bb Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Sat, 7 Dec 2024 17:01:20 -0500 Subject: [PATCH 66/68] Readd deleted blank line --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index 372c5b16b5b..890f08fa7aa 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -117,6 +117,7 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { + // Refactoring this to ExecutorService executor = Executors.newThreadPerTaskExecutor(new // NamingThreadFactory(name)) // and refactoring NamingThreadFactory to use virtual threads causes ServicesTest to hang forever From eee3e3c421a5383dbdc1ee85fcd282f0a5b55a15 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Sat, 7 Dec 2024 17:04:41 -0500 Subject: [PATCH 67/68] Fix whitespace --- .../evaluation/concurrent/ControlledWorkerScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java index 890f08fa7aa..32dd3dbae3e 100644 --- a/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java +++ b/tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/concurrent/ControlledWorkerScheduler.java @@ -117,7 +117,7 @@ public int getNumberOfTasks() { } private ExecutorService createExecutorService() { - + // Refactoring this to ExecutorService executor = Executors.newThreadPerTaskExecutor(new // NamingThreadFactory(name)) // and refactoring NamingThreadFactory to use virtual threads causes ServicesTest to hang forever From cbb504535ed0c42f5d530062844aac47644bc75f Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 11 Dec 2024 14:33:00 -0500 Subject: [PATCH 68/68] Simplify semaphore acquisition. --- .../sail/memory/benchmark/BaseConcurrentBenchmark.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java index 254a7158b67..fe6ba4661c9 100644 --- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java +++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/BaseConcurrentBenchmark.java @@ -63,7 +63,7 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { CountDownLatch latchDone = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; i++) { - semaphore.acquire(); + semaphore.acquireUninterruptibly(); try { executorService.submit(() -> { try { @@ -86,12 +86,9 @@ void threads(int threadCount, Runnable runnable) throws InterruptedException { } Future submit(Runnable runnable) { + semaphore.acquireUninterruptibly(); try { - semaphore.acquire(); return executorService.submit(runnable); - } catch (InterruptedException e) { - e.printStackTrace(); - return CompletableFuture.completedFuture(null); } finally { semaphore.release(); }