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

HPCC-32958 Roxie dynamic priority #19300

Open
wants to merge 2 commits into
base: candidate-9.8.x
Choose a base branch
from

Conversation

mckellyln
Copy link
Contributor

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@mckellyln
Copy link
Contributor Author

NOTE: this PR is an extension of existing PR:
#19300
which is from JIRA:
https://hpccsystems.atlassian.net/browse/HPCC-32964

@mckellyln mckellyln force-pushed the dynamic_priority branch 5 times, most recently from 5238e32 to 0e96a35 Compare November 14, 2024 19:36
Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32958

Jirabot Action Result:
Assigning user: [email protected]
Workflow Transition To: Merge Pending
Updated PR

@mckellyln mckellyln force-pushed the dynamic_priority branch 5 times, most recently from 1d71248 to 3e1e54b Compare November 21, 2024 18:36
@mckellyln mckellyln requested a review from ghalliday November 21, 2024 21:02
@mckellyln mckellyln force-pushed the dynamic_priority branch 4 times, most recently from aa08cb1 to d3f5445 Compare November 23, 2024 01:26
Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

Broadly looks great. Some fairly minor comments to improve readability.

if (tmpPriority < (int)priority)
{
dynPriority = tmpPriority;
if (dynPriority < 0)
Copy link
Member

Choose a reason for hiding this comment

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

probably not worth it, but this could be commoned up with the code in setFromWorkunit e.g. a setDynamicPriority() function.

int dynPriority = ctx->queryOptions().dynPriority;
if (dynPriority < origPriority)
{
unsigned newPri = ROXIE_SLA_PRIORITY + ROXIE_HIGH_PRIORITY;
Copy link
Member

Choose a reason for hiding this comment

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

minor: Introduce a function to map from a priority level to a mask - this code would then be simpler, and can reuse in createActivityFactory().

{
ctx->queryOptions().dynPriority = -1;
UWARNLOG("WARNING: %d msec dynamic adjustment threshold reached, shifting query to BG queue", dynPriorityAdjustTime);
p->queryHeader().activityId |= (ROXIE_SLA_PRIORITY + ROXIE_HIGH_PRIORITY);
Copy link
Member

Choose a reason for hiding this comment

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

Here and elsewhere - see comments in other PR about a new constant.

roxie/ccd/ccdserver.cpp Show resolved Hide resolved
// dynamically adj priority in the header activityId before sending
int tmpPriority;
updateFromContext(tmpPriority, ctx, "@priority", "_Priority");
if (tmpPriority > 1)
Copy link
Member

Choose a reason for hiding this comment

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

Would be clearer to have some constants for MinQueryPriority and MaxQueryPriority and compare against those. (Comparing > 1 would be clearer to compare with > 2, since that is leaking the next test into the bounds test).

unsigned priority;
mutable int dynPriority;
Copy link
Member

Choose a reason for hiding this comment

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

technically should be an atomic, but unlikely to cause any grief.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better as an unsigned so consistent with priority.

@mckellyln mckellyln force-pushed the dynamic_priority branch 6 times, most recently from abef643 to fdfe231 Compare January 5, 2025 23:03
@mckellyln
Copy link
Contributor Author

Updated for re-review.

Copy link
Member

@richardkchapman richardkchapman left a comment

Choose a reason for hiding this comment

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

I did not spot anything beyond what has already been mentioned

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

Thaks @mckellyln it looks good. One minor comment, but no need to change before merging. Please squash.

ctx->queryOptions().dynPriority = QUERY_BG_PRIORITY_VALUE;
unsigned dynAdjustMsec = (dynPriorityAdjustCycles * 1000ULL) / queryOneSecCycles();
UWARNLOG("WARNING: %d msec dynamic adjustment threshold reached, shifting query to BG queue", dynAdjustMsec);
p->queryHeader().activityId |= ROXIE_BG_PRIORITY;
Copy link
Member

Choose a reason for hiding this comment

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

To be truly correct if the constants change value this should remove ROXIE_PRIORITY_MASK first. Would it be better if this block was moved before the if() above?

Copy link
Contributor Author

@mckellyln mckellyln Jan 10, 2025

Choose a reason for hiding this comment

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

I agree, I can add a line so its -
+ p->queryHeader().activityId &= ~ROXIE_PRIORITY_MASK;
p->queryHeader().activityId |= ROXIE_BG_PRIORITY;

@ghalliday
Copy link
Member

@mckellyln please rebase ontop of the latest - which includes your first set of changes.

@mckellyln
Copy link
Contributor Author

mckellyln commented Jan 10, 2025

Squashed and rebased to latest. I can add that extra line to clear the priority mask also to make it more readable and correct no matter what the constants are.

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.

3 participants