Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support StressWorkerBench using consistent hash policy #18246

Merged
merged 6 commits into from
Oct 10, 2023

Conversation

twalluxio
Copy link
Contributor

What changes are proposed in this pull request?

This PR adds a --mode option for StressWorkerBench. This option allows user to choose from a range of file read policies. Possible option values are hash(default) and local-only.

If use hash, the config alluxio.client.file.dora.ConsistentHashPolicy is set to alluxio.client.file.dora.ConsistentHashPolicy.

If use local-only, that config is set to alluxio.client.file.dora.LocalWorkerPolicy.

The benchmark will parse this option, and choose the right policy. Also, it will print a log about the policy the user is using in both the benchmark and the policy factory.

Why are the changes needed?

In previous versions, the default policy is local-only.

However, in Alluxio, the default policy is hash, using alluxio.client.file.dora.ConsistentHashPolicy.

If user wants to use the local-only policy, add --mode local-only to the end of the benchmark command.

Copy link
Contributor

@jiacheliu3 jiacheliu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments, thanks for the work!

Comment on lines 100 to 105
@Parameter(names = {"--mode"},
description = "Decide which policy to use for file reads."
// + "Possible values are: [local-only, remote-only, hash]."
+ "Possible values are: [local-only, hash]."
+ "By default, the mode is 'hash'")
public String mMode = "hash";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use a enum here and the values can then be LOCAL_ONLY, HASH

description = "the operation to perform. Options are [ReadArray, ReadByteBuffer, ReadFully,"

Let's only support LOCAL_ONLY and HASH. We can add a REMOTE_ONLY when we implement that policy.

Here the description can be

      description = "Specifies which worker the test process reads from."
          + "Possible values are: [" + Arrays.toString(YourEnumClass.values()) + "]"
          + "HASH - alluxio.client.file.dora.ConsistentHashPolicy"
          + "LOCAL_ONLY - alluxio.client.file.dora.LocalWorkerPolicy"
          + "The default is HASH."

You may replace the strings with enum/class names by code, as you see fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description should be a constant string, or it will report: Attribute value must be constant. Here I will use a string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

+ "HASH - alluxio.client.file.dora.ConsistentHashPolicy"
+ "LOCAL_ONLY - alluxio.client.file.dora.LocalWorkerPolicy"
+ "The default is HASH.")
public String mMode = "HASH";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use enum here instead of a string? Refer to my previous comment on how.

@@ -191,16 +191,18 @@ public void prepare() throws Exception {
"true");

// default mode value: hash, using consistent hash
if (Objects.equals(mParameters.mMode, "local-only")) {
// TODO(jiacheng): we may need a policy to only IO to remote worker
if (Objects.equals(mParameters.mMode, "LOCAL_ONLY")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here mParameters.mMode should be an enum so you just

switch (mParameters.mMode) {
  case LOCAL_ONLY: ...; break;
  case HASH: ...;break;
  default: throw new IllegalArgumentException("Unrecognized mode" + mParameters.mMode);
}

Copy link
Contributor

@jiacheliu3 jiacheliu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the work!

@jiacheliu3 jiacheliu3 changed the title Add file read mode selection option for StressWorkerBench Support StressWorkerBench using consistent hash policy Oct 10, 2023
@jiacheliu3 jiacheliu3 added the type-feature This issue is a feature request label Oct 10, 2023
@jiacheliu3
Copy link
Contributor

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit 3470e17 into Alluxio:main Oct 10, 2023
14 checks passed
@twalluxio twalluxio deleted the swb-mode-selection branch November 8, 2023 02:04
ssz1997 pushed a commit to ssz1997/alluxio that referenced this pull request Dec 15, 2023
### What changes are proposed in this pull request?
This PR adds a `--mode` option for StressWorkerBench. This option allows user to choose from a range of file read policies. Possible option values are `hash`(default) and `local-only`.

If use `hash`, the config `alluxio.client.file.dora.ConsistentHashPolicy` is set to `alluxio.client.file.dora.ConsistentHashPolicy`.

If use `local-only`, that config is set to `alluxio.client.file.dora.LocalWorkerPolicy`.

The benchmark will parse this option, and choose the right policy. Also, it will print a log about the policy the user is using in both the benchmark and the policy factory.

### Why are the changes needed?
In previous versions, the default policy is `local-only`.

However, in Alluxio, the default policy is `hash`, using `alluxio.client.file.dora.ConsistentHashPolicy`.

If user wants to use the `local-only` policy, add `--mode local-only` to the end of the benchmark command.
			pr-link: Alluxio#18246
			change-id: cid-29676a12710b9c815f3e55f84eb5e4226fea9ad7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature This issue is a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants