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

HIVE-28549: Limit the maximum number of operators merged by SharedWorkOptimizer #5492

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

okumin
Copy link
Contributor

@okumin okumin commented Oct 8, 2024

What changes were proposed in this pull request?

This PR would limit the maximum number of table scan operators which SWO tries to merge.

https://issues.apache.org/jira/browse/HIVE-28549

Why are the changes needed?

We observed SWO makes a negative impact when it merges too many, e.g. 50, operators. If operators are memory intensive, they might throw OOM or might slow down.

I believe we can resolve OOM with the following patch, but we still want an upper limit so that we can tune concurrency or RAM per operator reasonably.
#5478

Does this PR introduce any user-facing change?

No.

Is the change a dependency upgrade?

No.

How was this patch tested?

I added a qtest

Copy link

sonarcloud bot commented Oct 8, 2024

@okumin okumin changed the title [WIP] HIVE-28549: Limit the maximum number of operators merged by SharedWorkOptimizer HIVE-28549: Limit the maximum number of operators merged by SharedWorkOptimizer Oct 16, 2024
@okumin okumin marked this pull request as ready for review October 16, 2024 01:25
final List<TableScanOperator> scans = tableNameToOps.get(tableName);
if (batchSize == -1) {
batches.add(scans);
continue;
Copy link
Member

Choose a reason for hiding this comment

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

using continue keyword is a bad practice

ArrayListMultimap<String, TableScanOperator> tableNameToOps, int batchSize) {
if (batchSize == -1) {
return Collections.singletonList(sortedTables.stream().map(Entry::getKey)
.flatMap(tableName -> tableNameToOps.get(tableName).stream()).collect(Collectors.toList()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This puts all TS ops into a single List, regardless of their source. Maybe you intend the following code?

    if (batchSize == -1) {
      return sortedTables.stream()
          .map(entry -> tableNameToOps.get(entry.getKey()))
          .collect(Collectors.toList());
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I was just confused when I wrote the line. I modified it and ran some qtests which failed
e574161

Copy link

sonarcloud bot commented Nov 14, 2024

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

Successfully merging this pull request may close these issues.

4 participants