Skip to content

Commit

Permalink
Enable short circuit even domain socket is configured
Browse files Browse the repository at this point in the history
### Background

I found short circuit has better performance than domain socket.
But when i enable short-circuit read/write, alluxio client prefer to use
domain socket as default.

I want to use short-circuit read/write, even domain socket is ready in
AlluxioWorker.

### Discussion

I use a new property `alluxio.user.short.circuit.preferred` to control
the logic, which is backward compatible.

But i think it is better to use only
`alluxio.user.short.circuit.enabled` to judge whether to enable short
circuit.

pr-link: #10538
change-id: cid-981cb46b6b8cb919865b0b0ddc072e094c6ec661
  • Loading branch information
Hollyen authored and alluxio-bot committed Dec 13, 2019
1 parent 1570c68 commit 5ceb15b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Expand Up @@ -110,11 +110,17 @@ public static BlockInStream create(FileSystemContext context, BlockInfo info,
builder.setOpenUfsBlockOptions(options.getOpenUfsBlockOptions(blockId));
AlluxioConfiguration alluxioConf = context.getClusterConf();
boolean shortCircuit = alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED);
boolean shortCircuitPreferred =
alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_PREFERRED);
boolean sourceSupportsDomainSocket = NettyUtils.isDomainSocketSupported(dataSource);
boolean sourceIsLocal = dataSourceType == BlockInStreamSource.LOCAL;

// Short circuit
if (sourceIsLocal && shortCircuit && !sourceSupportsDomainSocket) {
// Short circuit is enabled when
// 1. data source is local node
// 2. alluxio.user.short.circuit.enabled is true
// 3. the worker's domain socket is not configuered
// OR alluxio.user.short.circuit.preferred is true
if (sourceIsLocal && shortCircuit && (shortCircuitPreferred || !sourceSupportsDomainSocket)) {
LOG.debug("Creating short circuit input stream for block {} @ {}", blockId, dataSource);
try {
return createLocalBlockInStream(context, dataSource, blockId, blockSize, options);
Expand Down
Expand Up @@ -57,9 +57,13 @@ private Factory() {} // prevent instantiation
public static DataWriter create(FileSystemContext context, long blockId, long blockSize,
WorkerNetAddress address, OutStreamOptions options) throws IOException {
AlluxioConfiguration alluxioConf = context.getClusterConf();
if (CommonUtils.isLocalHost(address, alluxioConf) && alluxioConf
.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED) && !NettyUtils
.isDomainSocketSupported(address)) {
boolean shortCircuit = alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED);
boolean shortCircuitPreferred =
alluxioConf.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_PREFERRED);

if (CommonUtils.isLocalHost(address, alluxioConf)
&& shortCircuit
&& (shortCircuitPreferred || !NettyUtils.isDomainSocketSupported(address))) {
if (options.getWriteType() == WriteType.ASYNC_THROUGH
&& alluxioConf.getBoolean(PropertyKey.USER_FILE_UFS_TIER_ENABLED)) {
LOG.info("Creating UFS-fallback short circuit output stream for block {} @ {}", blockId,
Expand Down
10 changes: 10 additions & 0 deletions core/common/src/main/java/alluxio/conf/PropertyKey.java
Expand Up @@ -3309,6 +3309,14 @@ public String toString() {
.setConsistencyCheckLevel(ConsistencyCheckLevel.WARN)
.setScope(Scope.CLIENT)
.build();
public static final PropertyKey USER_SHORT_CIRCUIT_PREFERRED =
new Builder(Name.USER_SHORT_CIRCUIT_PREFERRED)
.setDefaultValue(false)
.setDescription("When short circuit and domain socket both enabled, "
+ "prefer to use short circuit.")
.setConsistencyCheckLevel(ConsistencyCheckLevel.WARN)
.setScope(Scope.CLIENT)
.build();
public static final PropertyKey USER_METADATA_CACHE_ENABLED =
new Builder(Name.USER_METADATA_CACHE_ENABLED)
.setDefaultValue(false)
Expand Down Expand Up @@ -4458,6 +4466,8 @@ public static final class Name {
public static final String USER_UFS_BLOCK_READ_CONCURRENCY_MAX =
"alluxio.user.ufs.block.read.concurrency.max";
public static final String USER_SHORT_CIRCUIT_ENABLED = "alluxio.user.short.circuit.enabled";
public static final String USER_SHORT_CIRCUIT_PREFERRED =
"alluxio.user.short.circuit.preferred";
public static final String USER_WORKER_LIST_REFRESH_INTERVAL =
"alluxio.user.worker.list.refresh.interval";
public static final String USER_METADATA_CACHE_ENABLED =
Expand Down

0 comments on commit 5ceb15b

Please sign in to comment.