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

[native] Default task.max-drivers-per-task to hardware concurrency #24642

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

majetideepak
Copy link
Collaborator

@majetideepak majetideepak commented Feb 27, 2025

Description

The doc says task.max-drivers-per-task defaults to CPU count.
https://prestodb.io/docs/current/presto_cpp/properties.html#task-max-drivers-per-task
But it defaults to 16 in the code.
This config must default to the thread concurrency count for better user experience.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

Prestissimo (Native Execution)
* Fix task.max-drivers-per-task to use thread concurrency of the host

@majetideepak majetideepak requested review from steveburnett, elharo and a team as code owners February 27, 2025 15:57
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Feb 27, 2025
@prestodb-ci prestodb-ci requested review from a team, ScrapCodes and imsayari404 and removed request for a team February 27, 2025 15:57
@majetideepak majetideepak requested review from amitkdutta and aditi-pandit and removed request for ScrapCodes and imsayari404 February 27, 2025 16:00
steveburnett
steveburnett previously approved these changes Feb 27, 2025
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull branch, local doc build, looks good. Thanks!

Copy link
Contributor

@czentgr czentgr left a comment

Choose a reason for hiding this comment

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

Thanks for this!

@@ -76,21 +76,6 @@ std::string ConfigBase::capacityPropertyAsBytesString(
velox::config::CapacityUnit::BYTE));
}

bool ConfigBase::registerProperty(
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, looks like dead code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes.

ASSERT_EQ(config.maxDriversPerTask(), 16);
// std::thread::hardware_concurrency() value depends on the host.
// Most hardware should have atleast 8 threads.
ASSERT_GE(config.maxDriversPerTask(), 8);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to not use 8 hard coded here but also read it from std::thread::hardware_concurrency() and also to account for when this is 0?
We've run in all kinds of build envs so this could be a failure point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point!

"{} must be one of 'LEAF', 'INTERMEDIATE', or 'DEFAULT'",
kPoolType);
return value;
static const std::unordered_set<std::string> kPoolTypes = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

format changes

czentgr
czentgr previously approved these changes Feb 27, 2025
Copy link
Contributor

@czentgr czentgr left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @majetideepak. Small nit.

auto numThreads = std::thread::hardware_concurrency();
// The spec says std::thread::hardware_concurrency() might return 0.
if (numThreads <= 0) {
numThreads = 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit : Add static constant for this number.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is in an anonymous namespace. I don't think there is any advantage of using a constant here. All the default config values use literals for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

@majetideepak : All of the SystemConfig property defaults are either in the registeredProps_ map (where static constant isn't needed) or they have individual SystemConfig functions to retrieve the properties if there is some logic like this which could use a default value. They aren't in anonymous namespace functions.

We should be consistent with that in general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using an anonymous namespace is equivalent to using static. https://stackoverflow.com/questions/4422507/how-are-unnamed-namespaces-superior-to-the-static-keyword
I can add a constant.

Copy link
Contributor

Choose a reason for hiding this comment

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

@majetideepak : Thanks for that article. Agree that we should reduce our use of static constants and functions as much as possible for external linkage.

Made the review comment largely because of consistency with the rest of this class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@aditi-pandit I ended up removing the constant. I added a check instead.

@majetideepak majetideepak force-pushed the fix-default-workers branch 2 times, most recently from 989f107 to 6dc3a20 Compare February 27, 2025 20:38
@majetideepak majetideepak requested a review from czentgr February 27, 2025 20:40
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @majetideepak

@majetideepak
Copy link
Collaborator Author

@steveburnett Can you approve this again? Thanks.

Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull updated branch, new local doc build.

@majetideepak majetideepak merged commit f6c9750 into prestodb:master Feb 28, 2025
61 checks passed
@majetideepak majetideepak deleted the fix-default-workers branch February 28, 2025 17:41
/// Registers an extra property in the config.
/// Returns true if succeeded, false if failed (due to the property already
/// registered).
bool registerProperty(
Copy link
Member

Choose a reason for hiding this comment

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

Hey @majetideepak , why do we remove this? We still have usage of this function inside meta.

Copy link
Contributor

Choose a reason for hiding this comment

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

In OSS, its unused. We should probably add some tests or at least leave a comment about its usage.

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

Successfully merging this pull request may close these issues.

7 participants