Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Replace thread-sharing infrastructure with nylon-threads (#5909)
Browse files Browse the repository at this point in the history
Replace thread-sharing infrastructure with `nylon-threads`
  • Loading branch information
carterkozak authored Feb 25, 2022
1 parent 854184f commit ee91415
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 280 deletions.
1 change: 1 addition & 0 deletions atlasdb-cassandra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
explicitShadow project(":commons-api")
explicitShadow project(':timestamp-impl')
explicitShadow project(":atlasdb-impl-shared")
explicitShadow 'com.palantir.nylon:nylon-threads'

explicitShadow ('com.palantir.cassandra:cassandra-thrift:' + libVersions.palantir_cassandra_thrift) {
exclude group: 'org.apache.httpcomponents'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import com.palantir.atlasdb.keyvalue.cassandra.pool.CassandraClientPoolMetrics;
import com.palantir.atlasdb.util.MetricsManager;
import com.palantir.common.base.FunctionCheckedException;
import com.palantir.common.concurrent.ThreadNames;
import com.palantir.common.pooling.PoolingContainer;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.nylon.threads.ThreadNames;
import com.palantir.util.TimedRunner;
import com.palantir.util.TimedRunner.TaskContext;
import java.lang.management.ManagementFactory;
Expand Down
1 change: 1 addition & 0 deletions atlasdb-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
api group: "jakarta.annotation", name: "jakarta.annotation-api"
api group: "org.slf4j", name: "slf4j-api"

implementation "com.palantir.nylon:nylon-threads"
implementation group: "org.xerial.snappy", name: "snappy-java", version: libVersions.snappy
implementation group: "com.github.ben-manes.caffeine", name: "caffeine"
implementation group: "com.googlecode.protobuf-java-format", name: "protobuf-java-format", version: "1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.palantir.atlasdb.util;

import com.palantir.common.concurrent.ThreadNames;
import com.palantir.nylon.threads.ThreadNames;
import java.util.concurrent.Callable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.palantir.atlasdb.util;

import com.palantir.common.concurrent.ThreadNames;
import com.palantir.nylon.threads.ThreadNames;

/**
* Whenever this runnable is run, for the duration of the call we will have a new thread name.
Expand Down
1 change: 1 addition & 0 deletions atlasdb-dbkvs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
compile project(':commons-api')
implementation group: 'com.palantir.conjure.java.api', name: 'service-config'

implementation "com.palantir.nylon:nylon-threads"
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.auto.service:auto-service-annotations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
import com.palantir.common.base.Throwables;
import com.palantir.common.collect.Maps2;
import com.palantir.common.concurrent.PTExecutors;
import com.palantir.common.concurrent.ThreadNames;
import com.palantir.exception.PalantirSqlException;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
Expand All @@ -102,6 +101,7 @@
import com.palantir.nexus.db.sql.AgnosticResultRow;
import com.palantir.nexus.db.sql.AgnosticResultSet;
import com.palantir.nexus.db.sql.SqlConnection;
import com.palantir.nylon.threads.ThreadNames;
import com.palantir.util.crypto.Sha256Hash;
import com.palantir.util.paging.AbstractPagingIterable;
import com.palantir.util.paging.SimpleTokenBackedResultsPage;
Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-5909.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Replace thread-sharing infrastructure with `nylon-threads`
links:
- https://github.com/palantir/atlasdb/pull/5909
1 change: 1 addition & 0 deletions commons-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies {
compile project(':atlasdb-commons')
compile project(':commons-annotations')

implementation "com.palantir.nylon:nylon-threads"
implementation 'com.google.guava:guava'

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.palantir.common.concurrent;

import com.palantir.nylon.threads.ThreadNames;
import java.util.concurrent.Callable;

/**
Expand Down
1 change: 1 addition & 0 deletions commons-db/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {
compile project(":commons-api")
compile project(":commons-proxy")

implementation "com.palantir.nylon:nylon-threads"
implementation group: 'commons-dbutils', name: 'commons-dbutils', version: libVersions.commons_dbutils
implementation group: 'org.apache.commons', name: 'commons-lang3'
implementation group: 'commons-io', name: 'commons-io'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableList;
import com.palantir.common.base.Throwables;
import com.palantir.common.concurrent.PTExecutors;
import com.palantir.common.concurrent.ThreadNames;
import com.palantir.common.concurrent.ThreadNamingCallable;
import com.palantir.db.oracle.JdbcHandler;
import com.palantir.db.oracle.JdbcHandler.BlobHandler;
Expand All @@ -32,6 +31,7 @@
import com.palantir.nexus.db.monitoring.timer.SqlTimer;
import com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString;
import com.palantir.nexus.db.sql.monitoring.logger.SqlLoggers;
import com.palantir.nylon.threads.ThreadNames;
import com.palantir.sql.Connections;
import com.palantir.sql.PreparedStatements;
import com.palantir.sql.ResultSets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.palantir.nexus.db.sql;

import com.palantir.common.concurrent.ThreadNames;
import com.palantir.common.concurrent.ThreadNamingCallable;
import com.palantir.exception.PalantirSqlException;
import com.palantir.logsafe.Preconditions;
Expand All @@ -26,6 +25,7 @@
import com.palantir.nexus.db.SQLConstants;
import com.palantir.nexus.db.ThreadConfinedProxy;
import com.palantir.nexus.db.sql.monitoring.logger.SqlLoggers;
import com.palantir.nylon.threads.ThreadNames;
import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.SQLException;
Expand Down
1 change: 1 addition & 0 deletions commons-executors/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ libsDirName = file('build/artifacts')
dependencies {
compile project(":commons-executors-api")
compile "com.palantir.tracing:tracing"
implementation "com.palantir.nylon:nylon-threads"
implementation "com.palantir.tritium:tritium-metrics"
implementation "org.jboss.threads:jboss-threads"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.nylon.threads.NylonExecutor;
import com.palantir.tracing.Tracers;
import com.palantir.tritium.metrics.MetricRegistries;
import com.palantir.tritium.metrics.registry.SharedTaggedMetricRegistries;
Expand All @@ -52,7 +53,6 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.jboss.threads.ViewExecutor;

/**
* Please always use the static methods in this class instead of the ones in {@link
Expand Down Expand Up @@ -175,14 +175,13 @@ public static ExecutorService newCachedThreadPoolWithMaxThreads(int maxThreads,
.name(name)
.executor(PTExecutors.wrap(
name,
new AtlasRenamingExecutorService(
ViewExecutor.builder(SHARED_EXECUTOR.get())
.setMaxSize(Math.min(Short.MAX_VALUE, maxThreads))
.setQueueLimit(0)
.setUncaughtHandler(AtlasUncaughtExceptionHandler.INSTANCE)
.build(),
AtlasUncaughtExceptionHandler.INSTANCE,
AtlasRenamingExecutorService.threadNameSupplier(name))))
NylonExecutor.builder()
.name(name)
.executor(SHARED_EXECUTOR.get())
.maxThreads(maxThreads)
.queueSize(0)
.uncaughtExceptionHandler(AtlasUncaughtExceptionHandler.INSTANCE)
.build()))
// Unhelpful for cached executors
.reportQueuedDuration(false)
.build();
Expand Down Expand Up @@ -269,14 +268,12 @@ public static ExecutorService newFixedThreadPool(int numThreads, String name) {
SharedTaggedMetricRegistries.getSingleton(),
PTExecutors.wrap(
name,
new AtlasRenamingExecutorService(
ViewExecutor.builder(SHARED_EXECUTOR.get())
.setMaxSize(Math.min(numThreads, Short.MAX_VALUE))
.setQueueLimit(Integer.MAX_VALUE)
.setUncaughtHandler(AtlasUncaughtExceptionHandler.INSTANCE)
.build(),
AtlasUncaughtExceptionHandler.INSTANCE,
AtlasRenamingExecutorService.threadNameSupplier(name))),
NylonExecutor.builder()
.name(name)
.executor(SHARED_EXECUTOR.get())
.maxThreads(numThreads)
.uncaughtExceptionHandler(AtlasUncaughtExceptionHandler.INSTANCE)
.build()),
name);
}

Expand Down

This file was deleted.

Loading

0 comments on commit ee91415

Please sign in to comment.