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] Move static functions from PrestoTask to Util. #22617

Closed
wants to merge 1 commit into from

Conversation

amitkdutta
Copy link
Contributor

@amitkdutta amitkdutta commented Apr 26, 2024

Description

Minor refactor to move static tasks from PrestoTask struct to Util.

Motivation and Context

We are trying to make PrestoTask a class instead of a struct for better encapsulation. Moving static methods out of the struct makes this easier. Besides the functions we are moving aren't a good fit for PrestoTask.

Impact

No impact.

Test Plan

Existing unit tests

@amitkdutta amitkdutta requested a review from a team as a code owner April 26, 2024 16:35
@amitkdutta amitkdutta marked this pull request as draft April 26, 2024 16:35
@amitkdutta amitkdutta marked this pull request as ready for review April 26, 2024 17:01
@amitkdutta amitkdutta changed the title [WIP] [native] Move static functions from PrestoTask to Util. [native] Move static functions from PrestoTask to Util. Apr 26, 2024
Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

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

@amitkdutta thanks for the improvement!

@@ -31,4 +31,9 @@ std::shared_ptr<folly::SSLContext> createSSLContext(
const std::string& clientCertAndKeyPath,
const std::string& ciphers);

/// Returns process-wide CPU time in nanoseconds.
long getProcessCpuTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/getProcessCpuTime/getProcessCpuTimeNs/?

/// Returns process-wide CPU time in nanoseconds.
long getProcessCpuTime();

std::string taskNumbersToString(const std::array<size_t, 5>& taskNumbers);
Copy link
Contributor

Choose a reason for hiding this comment

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

const std::array<size_t, 5>& taskNumbers

@@ -220,7 +221,7 @@ proxygen::RequestHandler* TaskResource::createOrUpdateTaskImpl(
folly::via(
httpSrvCpuExecutor_,
[this, &body, taskId, createOrUpdateFunc]() {
const auto startProcessCpuTime = PrestoTask::getProcessCpuTime();
const auto startProcessCpuTime = util::getProcessCpuTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

NYC: s/startProcessCpuTime/startProcessCpuTimeNs/

@@ -775,27 +763,6 @@ void PrestoTask::updateExecutionInfoLocked(
prestoTaskStats);
}

/*static*/ std::string PrestoTask::taskNumbersToString(
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to keep this as static method of PrestoTask as the states are specific to PrestoTask internal

s/taskNumbersToString/taskStatesToString/

@@ -31,4 +31,9 @@ std::shared_ptr<folly::SSLContext> createSSLContext(
const std::string& clientCertAndKeyPath,
const std::string& ciphers);

/// Returns process-wide CPU time in nanoseconds.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to avoid files / classes named Util as they tend to become a "dumping ground" for lots of unrelated code. It would be better to come with more specific names.

@amitkdutta
Copy link
Contributor Author

Closing this in favor of #22662

@amitkdutta amitkdutta closed this May 3, 2024
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.

None yet

3 participants