Class Platform
java.lang.Object
org.opends.server.util.Platform
Utility class for getting the default number of worker threads.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intComputes the optimal number of reader threads based on the number of CPUs in the system.static intComputes the optimal number of writer threads based on the number of CPUs in the system.static booleanReturnstrueif virtual threads should be used.static ReadWriteLockReturns a new fair reentrant read-write lock.static ReadWriteLockReturns a new unfair non-reentrant read-write lock.static ThreadrunInVirtualThread(String name, Runnable task) Creates a new virtual thread with the provided name and task and then starts it.
-
Method Details
-
computeDefaultNumberOfReaderThreads
public static int computeDefaultNumberOfReaderThreads()Computes the optimal number of reader threads based on the number of CPUs in the system. The formula is the result of searchrate and modrate benchmarks performed on modern quad-core laptops and high performance 16-core NUMA lab machines.- Returns:
- The optimal number of reader threads based on the number of CPUs in the system.
-
computeDefaultNumberOfWriterThreads
public static int computeDefaultNumberOfWriterThreads()Computes the optimal number of writer threads based on the number of CPUs in the system. This setting should should be used for sizing threads pools in components which are responsible for performing updates to the backend database (e.g. cleaners, TTL, replay threads).Testing found that the optimal value is similar to the number of reader threads. Adding more threads does not yield greater performance due to contention on the database transaction log. Beyond this the threads simply queue up behind other blocked threads and essentially become extensions to the work queue.
The replication replay thread pool is sized to the nearest power of two so, unlike the reader thread count, this method does not add a hyper-threading "fudge factor" in order to avoid further adjustment.
- Returns:
- The optimal number of writer threads based on the number of CPUs in the system.
-
isVirtualThreadsEnabled
public static boolean isVirtualThreadsEnabled()Returnstrueif virtual threads should be used.- Returns:
trueif virtual threads should be used
-
runInVirtualThread
-
newFairReentrantReadWriteLock
Returns a new fair reentrant read-write lock.- Returns:
- a new fair reentrant read-write lock
-
newUnfairNonReentrantReadWriteLock
Returns a new unfair non-reentrant read-write lock.. Used in cases where the write lock is highly contended such that unfair scheduling brings significant benefits. Testing indicates that stamped locks are slightly more performant than unfair reentrant read-write locks and can be much more performant (~50%) than fair reentrant read-write locks.- Returns:
- a new unfair non-reentrant read-write lock
-