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

[#1303] refactor(client): using the configOption in RssTezConfig #1413

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lifeSo
Copy link
Collaborator

@lifeSo lifeSo commented Jan 1, 2024

What changes were proposed in this pull request?

Improvement: using the configOption in RssTezConfig #1303

Why are the changes needed?

Fix: #1303

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Unit test

@lifeSo lifeSo changed the title [#1303] Improvement: using the configOption in RssTezConfig #1303 [#1303] refactor(client): using the configOption in RssTezConfig #1303 Jan 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 1, 2024

Codecov Report

Attention: 79 lines in your changes are missing coverage. Please review.

Comparison is base (15a399a) 53.43% compared to head (79a08b2) 54.88%.
Report is 4 commits behind head on master.

Files Patch % Lines
...main/java/org/apache/tez/common/TezClientConf.java 95.57% 11 Missing and 2 partials ⚠️
...java/org/apache/uniffle/common/config/RssConf.java 0.00% 13 Missing ⚠️
...c/main/java/org/apache/tez/common/RssTezUtils.java 78.57% 5 Missing and 4 partials ⚠️
...n/java/org/apache/tez/dag/app/RssDAGAppMaster.java 77.77% 7 Missing and 1 partial ⚠️
...library/common/shuffle/impl/RssTezFetcherTask.java 0.00% 8 Missing ⚠️
...tez/runtime/library/input/RssUnorderedKVInput.java 0.00% 8 Missing ⚠️
.../org/apache/uniffle/common/config/RssBaseConf.java 0.00% 5 Missing ⚠️
...rg/apache/tez/dag/app/TezRemoteShuffleManager.java 60.00% 3 Missing and 1 partial ⚠️
...rary/common/shuffle/orderedgrouped/RssShuffle.java 50.00% 4 Missing ⚠️
...on/shuffle/orderedgrouped/RssShuffleScheduler.java 72.72% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1413      +/-   ##
============================================
+ Coverage     53.43%   54.88%   +1.45%     
- Complexity     2723     2737      +14     
============================================
  Files           419      402      -17     
  Lines         23992    22015    -1977     
  Branches       2046     2063      +17     
============================================
- Hits          12820    12083     -737     
+ Misses        10378     9201    -1177     
+ Partials        794      731      -63     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lifeSo lifeSo force-pushed the feature_1303_configuration branch 2 times, most recently from d1b1f26 to 529c34c Compare January 2, 2024 03:25
@zuston
Copy link
Member

zuston commented Jan 2, 2024

I like this PR that refactor the client config. Could you help fix the failed test cases

@zuston
Copy link
Member

zuston commented Jan 2, 2024

Could you help review this? @zhengchenyu

@lifeSo
Copy link
Collaborator Author

lifeSo commented Jan 6, 2024

I like this PR that refactor the client config. Could you help fix the failed test cases

Ok, I will fix the failed test cases recently.

@lifeSo lifeSo force-pushed the feature_1303_configuration branch 10 times, most recently from 1869dd1 to 7498984 Compare January 8, 2024 06:49
@lifeSo lifeSo changed the title [#1303] refactor(client): using the configOption in RssTezConfig #1303 [#1303] refactor(client): using the configOption in RssTezConfig Jan 8, 2024
@jerqi
Copy link
Contributor

jerqi commented Jan 8, 2024

ping @zhengchenyu

appId.toString(), sessionToken, conf, appId.toString(), client, null);
appId.toString(),
sessionToken,
new TezClientConf(conf),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we construct TezClientConf directly? Then we will ignore conversion process!

Copy link
Collaborator Author

@lifeSo lifeSo Jan 9, 2024

Choose a reason for hiding this comment

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

I think there needs a way to init and read configuration, like ShuffleServerConf 、DashboardConf、CoordinatorConf read config from fileName:

  public ShuffleServerConf(String fileName) {
    super();
    boolean ret = loadConfFromFile(fileName);
    if (!ret) {
      throw new IllegalStateException("Fail to load config file " + fileName);
    }
  }
  public DashboardConf(String fileName) {
    super();
    boolean ret = loadConfFromFile(fileName);
    if (!ret) {
      throw new IllegalStateException("Fail to load config file " + fileName);
    }
  }
  public CoordinatorConf(String fileName) {
    super();
    boolean ret = loadConfFromFile(fileName);
    if (!ret) {
      throw new IllegalStateException("Fail to load config file " + fileName);
    }
  }

And the only difference is TezClientConf init from configuration。

Copy link
Collaborator

Choose a reason for hiding this comment

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

I means that new TezClientConf() without any parameter, then set TEZ_RSS_TEST_MODE_ENABLE.
Then TezClientConf without any parameter will be zero cost.
Here we must load configuration, I think it is not neccessary. Because the configuration in TezClientConf(new Configuration) doesn't pass any useful config.

Copy link
Collaborator Author

@lifeSo lifeSo Jan 11, 2024

Choose a reason for hiding this comment

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

I think set TEZ_RSS_TEST_MODE_ENABLE should be obvious, and not like hidden in TezClientConf().

The normal case should read config from client side by Configuration, and convert to TezClientConfig, so there need TezClientConfig(new Configuration()).
And no need new TezClientConfig(), because if so, there will be default config and meanless.

So, I changed the test case to be:TezClientConf(new Configuration()), new Configuration() just like conf from client side.

return loadConfFromHadoopConfig(config, ConfigUtils.getAllConfigOptions(TezClientConf.class));
}

public RssConf toRssConf() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

TezClientConf is extended from RssBaseConf, RssBaseConf is extended from RssConf. So is this method still necessary?

Copy link
Collaborator Author

@lifeSo lifeSo Jan 9, 2024

Choose a reason for hiding this comment

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

It is necessary.

  public RssConf toRssConf() {
    RssConf rssConf = new RssConf();
    for (Map.Entry<String, Object> entry : getAll()) {
      String key = entry.getKey();
      if (!key.startsWith(TEZ_RSS_CONFIG_PREFIX)) {
        continue;
      }
      key = key.substring(TEZ_RSS_CONFIG_PREFIX.length());
      rssConf.setString(key, String.valueOf(entry.getValue()));
    }
    return rssConf;
  }

Between the conversion, to RssConf, removed prefex. like:

      key = key.substring(TEZ_RSS_CONFIG_PREFIX.length());
      rssConf.setString(key, String.valueOf(entry.getValue()));

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you!
But I don't know the design of these issue. How about RssClientConfig?
Maybe RssClientConfig should be extended from RssConf or RssBaseConf. RssTezConfig should be extended from RssClientConfig.
The the config key in RssXXXConfig should not be start with "tez", and the config key in hadoop Configuration should be start with "tez". That's my understanding, maybe it is wrong.

What do you think? @lifeSo

@zuston Can you give us some advice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In now design, the config in Tez client, start with "tez.",
similar, the config in Spark client, start with "spark.".
And there is also leading substring in RssSparkConfig:

  public static RssConf toRssConf(SparkConf sparkConf) {
    RssConf rssConf = new RssConf();
    for (Tuple2<String, String> tuple : sparkConf.getAll()) {
      String key = tuple._1;
      if (!key.startsWith(SPARK_RSS_CONFIG_PREFIX)) {
        continue;
      }
      key = key.substring(SPARK_RSS_CONFIG_PREFIX.length());
      rssConf.setString(key, tuple._2);
    }
    return rssConf;
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If some tez config not start with "tez.", it will be confusing because some default tez config is start with 'tez.'.

eg:

https://github.com/apache/tez/blob/master/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java

@@ -195,15 +190,15 @@ protected FetchResult callInternal() throws Exception {
.hadoopConf(hadoopConf)
.idHelper(new TezIdHelper())
.expectedTaskIdsBitmapFilterEnable(expectedTaskIdsBitmapFilterEnable)
.rssConf(RssTezConfig.toRssConf(this.conf)));
.rssConf(this.conf.toRssConf()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with toRssConf. Can we pass this.conf directly?

Copy link
Collaborator Author

@lifeSo lifeSo Jan 9, 2024

Choose a reason for hiding this comment

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

I think not, the RSS_STORAGE_TYPE in TezClientConf is 'tez.rss.storage.type',

  public static final ConfigOption<String> RSS_STORAGE_TYPE =
      ConfigOptions.key("tez.rss.storage.type")
          .stringType()
          .defaultValue("MEMORY_LOCALFILE")
          .withDescription("");

But in ShuffleReadClientImpl.java, when get storageType, it call:
final String storageType = builder.getRssConf().get(RssClientConf.RSS_STORAGE_TYPE);

The problem is RssClientConf.RSS_STORAGE_TYPE is:

  public static final ConfigOption<String> RSS_STORAGE_TYPE =
      ConfigOptions.key("rss.storage.type")
          .stringType()
          .defaultValue("")
          .withDescription("Supports MEMORY_LOCALFILE, MEMORY_HDFS, MEMORY_LOCALFILE_HDFS");

There is no prefix : 'tez.' .

So, there need the conversion to delete prefix: 'tez'.

@zhengchenyu
Copy link
Collaborator

It is a great PR! The code about config will be cleaner!
But I've always had a question. There are a lot of transitions from Configuration to RssConf, then from RssConf to Configuration. It seems strange.
In this PR, I think @lifeSo used cache Configuration in TezClientConf, it is more efficient, but additional memory is required. @zuston What do you think of this approach?

@zuston
Copy link
Member

zuston commented Jan 9, 2024

In this PR, I think @lifeSo used cache Configuration in TezClientConf, it is more efficient, but additional memory is required.

LGTM. It looks the memory will not consume much more. If I'm wrong, feel free to correct.

@lifeSo lifeSo force-pushed the feature_1303_configuration branch 2 times, most recently from 7fc7d6d to 79a08b2 Compare January 9, 2024 19:58
@lifeSo
Copy link
Collaborator Author

lifeSo commented Jan 9, 2024

I summarized the usage of TezClientConf, and why need the transitions:

  • GetShuffleServerRequest & GetShuffleServerResponse & IdUtils & InputContextUtils
    no nedd conf

  • RssDAGAppMaster
    need TezClientConf to get arguement and transitions.

  • TezRemoteShuffleManager
    need TezClientConf and configuration ,to get arguement and transitions.

  • RssTezUtils
    need RssTezUtils

  • ShuffleAssignmentsInfoWritable
    no need conf

  • TezClassLoader
    no need conf

  • UmbilicalUtils
    need configuration to pass arguement

  • RssTezAMPolicyProvider
    no conf

  • RemoteFetchedInput
    no conf

  • RssShuffleManager
    no need TezClientConf to get conf but transitions is needed.

  • RssSimpleFetchedInputAllocator
    need configuration and TezClientConf to get some conf

  • RssTezFetcher
    no need configuration and TezClientConf

  • RssTezFetcherTask
    need TezClientConf to get argue,also need Configuration to get transitions.

  • RssInMemoryMerger & RssMergeManager & RssShuffle & RssShuffleScheduler
    need configuration to call other Tez class, no need TezClientConf

  • RssTezBypassWriter & RssTezShuffleDataFetcher & WriteBuffer

  • WriteBufferManager
    no need , just pass RssConf.

  • RssSorter & RssUnSorter
    need Configuration and use only in super()

  • RssTezPerPartitionRecord
    no conf

  • RssOrderedPartitionedKVOutput & RssUnorderedKVOutput & RssUnorderedPartitionedKVOutput
    no nedd TezClientConf.

@zuston
Copy link
Member

zuston commented Jan 12, 2024

cc @zhengchenyu I'm not familiar with Tez code.

@zhengchenyu
Copy link
Collaborator

cc @zhengchenyu I'm not familiar with Tez code.

This PR does not involve the core logic of Tez. This PR is only about how the MR/Tez/Spark client uses configuration.
I'm still a little confused about how to design the client config.

Copy link
Member

@zuston zuston left a comment

Choose a reason for hiding this comment

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

Emm... I take a look about current impl, I don't think we should take the tez prefix into the config key, you can refer the spark's RssClientConf .

In spark's partial configOption, we just extract the spark's conf like spark.rss.client.type into RssConf, that means we could share some general configOption defined in the RssClientConf. So you just only create the TezClientConfig.java, which could define some tez specified configOptions, shareable configs could use defined in RssClientConf. cc @zhengchenyu

@zhengchenyu
Copy link
Collaborator

zhengchenyu commented Jan 12, 2024

Emm... I take a look about current impl, I don't think we should take the tez prefix into the config key, you can refer the spark's RssClientConf .

In spark's partial configOption, we just extract the spark's conf like spark.rss.client.type into RssConf, that means we could share some general configOption defined in the RssClientConf. So you just only create the TezClientConfig.java, which could define some tez specified configOptions, shareable configs could use defined in RssClientConf. cc @zhengchenyu

@zuston I agree with you!
If so, RssClientConf should be extended from RssClientConf (But for now, RssClientConf is extended from RssBaseConf ), and does not take the tez prefix into the config key.
I think the tez prefix should be considered in the TezConfiguration. @lifeSo what about you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Using the configOption in RssTezConfig
5 participants