Skip to content

Only grant or reject spillback lease request - #20050

Merged
ericl merged 24 commits into
ray-project:masterfrom
jjyao:jjyao/spillback
Nov 15, 2021
Merged

ericl merged 24 commits into
ray-project:masterfrom
jjyao:jjyao/spillback

Conversation

@jjyao

@jjyao jjyao commented Nov 4, 2021 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Status quo:
GCS based actor scheduling: For infeasible and unavailable actors, they are waited inside GCS until resource is available. For available actors, GCS picks the best raylet and sends lease request to it. The chosen raylet can either grant or reject the lease, but no spillback to other raylets.

Raylet based normal task scheduling: For infeasible tasks, they are waited inside the raylet until resource is available. For unavailable tasks, they are spilled back to the best feasible raylet and waited there. For available tasks, they are either granted locally or spilled back to other better raylets.

Problem:
Since raylet's local view of other raylets can be stale (stale until the next report), there can be lots of unnecessary spillbacks for a single task. Also each spillback updates local view of other raylets (i.e. subtract cpu) even though they are likely to be redirected again, which cause the local view even more inaccurate. This is particular problematic when we launch many tasks in a short time (e.g. Dataset read tasks). This is actually one of the problems GCS based actor scheduling solved: https://docs.google.com/document/d/1oPMqEj9YLCh75oArgN7XrViOQnoTdeTtg6QNRMMNVB0/edit#

Proposal:
While still doing distributed normal task scheduling, we can let the first raylet of the task act like a local gcs (i.e. only first raylet is responsible for finding the best raylet to run the task): For infeasible tasks, they are waited inside first raylet and for unavailable tasks, they are waited inside the best feasible raylet until resource is available. For available task, first raylet either grant the lease or spillback to the best raylet. The chosen raylet either grants the lease if the local available resources are enough or reject otherwise (can happen when the first raylet had a stale view of the chosen raylet), but no spillback to other raylets. If the lease is rejected, it will go back to the first raylet for rescheduling (hopefully the local view is refreshed).
Pros: Simpler to reason about the scheduling behavior since there is a single decision maker (i.e first raylet). Avoid the excessive spillbacks due to stale local resource view.

Related issue number

Checks

@jjyao

jjyao commented Nov 4, 2021

Copy link
Copy Markdown
Contributor Author

@scv119

scv119 commented Nov 4, 2021 •

Copy link
Copy Markdown
Contributor

This is a very clear description! for completeness, can you add a bit clarification for "available/unavailable/infeasible" task?

@rkooo567

rkooo567 commented Nov 4, 2021

Copy link
Copy Markdown
Contributor

Are there any concerns about head node raylet being overloaded? Also, can you write how the spillback works with this proposal in this doc? (For a comparison) https://docs.google.com/document/d/1nz68kjDvDi1ueHGVfo9O3lJ6imFR-OUnSHDb_mDnYNI/edit

@scv119

scv119 commented Nov 4, 2021

Copy link
Copy Markdown
Contributor

I think the missing part of the proposal is why it will work better.

After discuss with @rkooo567 I have some guess, such as it reduce the likelihood of stale views, and it's almost identical to GCS based scheduling if all tasks are submitted by driver.

@jjyao

jjyao commented Nov 4, 2021

Copy link
Copy Markdown
Contributor Author

This is a very clear description! for completeness, can you add a bit clarification for "available/unavailable/infeasible" task?

I think I probably didn't use the right terms:

available task means that there is available free resources and the task can be scheduled now.
unavailable task means that there is not enough free resources due to other running tasks but it's feasible without adding more resources to the cluster.
infeasible task means the task cannot run without adding more resources to the cluster.

@jjyao

jjyao commented Nov 4, 2021 •

Copy link
Copy Markdown
Contributor Author

Are there any concerns about head node raylet being overloaded? Also, can you write how the spillback works with this proposal in this doc? (For a comparison) https://docs.google.com/document/d/1nz68kjDvDi1ueHGVfo9O3lJ6imFR-OUnSHDb_mDnYNI/edit

I guess it should be fine since currently the first lease request for a task needs to go to the home raylet anyway. Also we can always launch a task to schedule other tasks remotely?

Added before & after for comparison.

@jjyao

jjyao commented Nov 4, 2021

Copy link
Copy Markdown
Contributor Author

Included proper round robin fix in this PR as well. Also changed dataset test to show that we can avoid _spread_resource_prefix (although the test is just a toy example). Going to test it out with real ML ingest workload.

@jjyao
jjyao marked this pull request as ready for review November 4, 2021 17:50
@jjyao
jjyao requested review from ericl and scv119 as code owners November 4, 2021 17:50
@rkooo567

rkooo567 commented Nov 4, 2021

Copy link
Copy Markdown
Contributor

the first lease request for a task needs to go to the home raylet anyway

So, the overhead is the same only until the first spillback, and after that it increases on a head raylet? Since previously, scheduling decisions were done from remote nodes whereas now everything is done from the head node raylet. I think "grant or lease" decision is really cheap compared to the scheduling overhead (only need to compare local resources to the task request vs comparing task requests to all nodes resources).

I feel like in this case, isn't decentralized scheduling is basically not working? (all scheuduling work is done at the home raylet, and other raylets only check if it is scheduleable locally or not, which is probably very cheap)?

@ericl ericl self-assigned this Nov 4, 2021
@ericl

ericl commented Nov 4, 2021

Copy link
Copy Markdown
Contributor

So, the overhead is the same only until the first spillback, and after that it increases on a head raylet?

In practice the home raylet is doing the vast majority of the work. You only get multiple spillbacks on rare edge conditions, so this will not appreciably change load.

It was never intended that subsequent raylets make policy decisions again, that's a flat out bug.

@jjyao

jjyao commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author

All the existing tests are passing. Would like to get the review started while I'm adding comments and tests.

Comment thread src/ray/raylet/node_manager.cc Outdated
normal_task_map = {normal_task_resources.GetResourceMap().begin(),
normal_task_resources.GetResourceMap().end()};
resources_data->set_resources_normal_task_timestamp(absl::GetCurrentTimeNanos());
if (is_actor_creation_task) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't we follow this for normal tasks as well? Seems that would simplify the logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don’t follow this to make it explicit that for normal task, we don’t use that normal task resources feedback loop. That only used by gcs actor scheduling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm I agree with @ericl here. Would it work if we changed this to be agnostic to actor creation tasks vs normal tasks? I think we just need two flags from the client here:

  • grant_or_reject (always true for GCS)
  • include_current_resources (always true for GCS to update resources view)

My higher level question here is if there's a known issue if we queue actor creation tasks instead of rejecting immediately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Going to always queue actor creation tasks as well to be consistent with normal tasks. We can still reject once they are queued.

Comment thread src/ray/raylet/node_manager.cc Outdated
}

cluster_task_manager_->QueueAndScheduleTask(task, reply, send_reply_callback_wrapper);
cluster_task_manager_->QueueAndScheduleTask(task, true, reply,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about avoiding calling QueueAndSchedule for grant_or_reject tasks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We still need to do normal QueueAndSchedule since we still need things like resolving/waiting args.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could probably simplify this further by using the same send_reply_callback_wrapper for both grant_or_reject = true/false. Right now, looks like we're calling send_reply_callback in 3 different places and it'd be nice to get this down to one for clarity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Changed to always use send_reply_callback_wrapper

@ericl ericl removed the do-not-merge Do not merge this PR! label Nov 5, 2021
@jjyao

jjyao commented Nov 9, 2021 •

Copy link
Copy Markdown
Contributor Author

Moved round robin related changes to a separate pr.

@stephanie-wang stephanie-wang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks good, just some suggestions for cleanups.

Comment thread src/ray/raylet/node_manager.cc Resolved
Comment thread src/ray/raylet/node_manager.cc Resolved
Comment thread src/ray/raylet/node_manager.cc Outdated
}

cluster_task_manager_->QueueAndScheduleTask(task, reply, send_reply_callback_wrapper);
cluster_task_manager_->QueueAndScheduleTask(task, true, reply,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could probably simplify this further by using the same send_reply_callback_wrapper for both grant_or_reject = true/false. Right now, looks like we're calling send_reply_callback in 3 different places and it'd be nice to get this down to one for clarity.

}

void ClusterResourceScheduler::FillResourceUsage(rpc::ResourcesData &resources_data) {
// Update local object store usage and report to other raylets.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this change related?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is #20026, but it's reverted because somehow it made 1tb autoscaler shuffling timed out. But when it's combined with this PR it worked so I just redo it here since it's small.

@ericl ericl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also LGTM, but wondering if we should trigger nightly tests on it, given the sensitivity of the change.

@jjyao

jjyao commented Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

@ericl
ericl merged commit 61778a9 into ray-project:master Nov 15, 2021
@jjyao
jjyao deleted the jjyao/spillback branch November 17, 2021 03:07
dstrodtman added a commit that referenced this pull request Oct 1, 2026
…ch fails (#66624)

## What

Two changes to the postmerge `:book: doc: apply redirects` step in
`.buildkite/doc.rayci.yml`:

1. Fail the step at the Secrets Manager fetch, with a message that names
the secret and the permission it needs, when `get-secret-value` fails or
returns an empty value. Previously `export RTD_API_TOKEN="$(aws ...)"`
returned `export`'s status rather than `aws`'s. The step fell through to
`rtd-redirects apply` with an empty token, which failed with
`RTD_API_TOKEN is not set. Export your RtD API token before running.`
That message reads like a local-environment problem and hides the real
AWS error a few lines up.
2. Document the IAM permission the runner role needs, in the step
comment.

## Why: the step has never been able to read its token

Every master postmerge run of this step since it was enabled in #66024
and reworked in #66427 has failed at the secret fetch, for example
[postmerge
#20026](https://buildkite.com/ray-project/postmerge/builds/20026) and
[#20049](https://buildkite.com/ray-project/postmerge/builds/20049). The
job log shows:

```
An error occurred (AccessDeniedException) when calling the GetSecretValue operation:
User: arn:aws:sts::029272617770:assumed-role/bk-runner-queue-small-branch-Role/i-... is not authorized to perform:
secretsmanager:GetSecretValue on resource: oss-ci/rtd-api-token
```

The `oss-ci/rtd-api-token` secret exists, but the runner role can't read
it. Release-branch builds such as
[#20050](https://buildkite.com/ray-project/postmerge/builds/20050)
aren't affected, because the step's branch guard skips them before the
fetch.

## IAM grant needed (CI infra)

This PR doesn't fix the access. It makes the failure say what's wrong.
For the step to work, the CI stack needs this grant:

- **Principal:** `bk-runner-queue-small-branch-Role`, the role of the
postmerge runner queue this step lands on. The step sets no
`instance_type`, so it runs on the default small queue.
- **Action:** `secretsmanager:GetSecretValue`
- **Resource:** the `oss-ci/rtd-api-token` secret in `us-west-2`,
account `029272617770`. Scope it to that one secret ARN, not a wildcard.
The token is deliberately isolated from other steps.
- If the secret uses a customer-managed KMS key, the role also needs
`kms:Decrypt` on that key.

`fossa analyze` (`.buildkite/others.rayci.yml`) reads
`oss-ci/fossa-api-key` the same way from an `instance_type: small` step,
so the grant should follow whatever pattern covers that secret.

Until the grant lands, this step keeps failing on master postmerge
builds, now with a clear message. It doesn't block master. If the
release-candidate noise is a problem in the meantime, re-adding a
`disabled` tag to the step turns it off, as the step comment describes.

## Not a duplicate

No open PR touches the redirect apply step. This follows up on #66024
and #66427.

## Testing

- Pulled the command block out of the YAML, replaced `$$` with `$` as
Buildkite does, and ran the apply branch under `bash -elc` with a stub
`aws`:
- `AccessDeniedException`, exit 254: the step prints the new error and
exits 1 without calling `apply`.
  - Empty secret value: the step prints the new error and exits 1.
- Non-empty value: the token is exported and reaches `rtd-redirects
apply`.
- `pre-commit run --files .buildkite/doc.rayci.yml`: the generic
whitespace, end-of-file, and large-file hooks passed. No
language-specific hook applies to this file.
- No Buildkite run. The step is `skip-on-premerge`, so a PR build can't
exercise it. Its first real run is the next master postmerge build after
merge.

## AI assistance

AI assistance (Claude Code) prepared this change and ran the checks
above. The submitter reviews every changed line before merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ch fails (ray-project#66624)

## What

Two changes to the postmerge `:book: doc: apply redirects` step in
`.buildkite/doc.rayci.yml`:

1. Fail the step at the Secrets Manager fetch, with a message that names
the secret and the permission it needs, when `get-secret-value` fails or
returns an empty value. Previously `export RTD_API_TOKEN="$(aws ...)"`
returned `export`'s status rather than `aws`'s. The step fell through to
`rtd-redirects apply` with an empty token, which failed with
`RTD_API_TOKEN is not set. Export your RtD API token before running.`
That message reads like a local-environment problem and hides the real
AWS error a few lines up.
2. Document the IAM permission the runner role needs, in the step
comment.

## Why: the step has never been able to read its token

Every master postmerge run of this step since it was enabled in ray-project#66024
and reworked in ray-project#66427 has failed at the secret fetch, for example
[postmerge
ray-project#20026](https://buildkite.com/ray-project/postmerge/builds/20026) and
[ray-project#20049](https://buildkite.com/ray-project/postmerge/builds/20049). The
job log shows:

```
An error occurred (AccessDeniedException) when calling the GetSecretValue operation:
User: arn:aws:sts::029272617770:assumed-role/bk-runner-queue-small-branch-Role/i-... is not authorized to perform:
secretsmanager:GetSecretValue on resource: oss-ci/rtd-api-token
```

The `oss-ci/rtd-api-token` secret exists, but the runner role can't read
it. Release-branch builds such as
[ray-project#20050](https://buildkite.com/ray-project/postmerge/builds/20050)
aren't affected, because the step's branch guard skips them before the
fetch.

## IAM grant needed (CI infra)

This PR doesn't fix the access. It makes the failure say what's wrong.
For the step to work, the CI stack needs this grant:

- **Principal:** `bk-runner-queue-small-branch-Role`, the role of the
postmerge runner queue this step lands on. The step sets no
`instance_type`, so it runs on the default small queue.
- **Action:** `secretsmanager:GetSecretValue`
- **Resource:** the `oss-ci/rtd-api-token` secret in `us-west-2`,
account `029272617770`. Scope it to that one secret ARN, not a wildcard.
The token is deliberately isolated from other steps.
- If the secret uses a customer-managed KMS key, the role also needs
`kms:Decrypt` on that key.

`fossa analyze` (`.buildkite/others.rayci.yml`) reads
`oss-ci/fossa-api-key` the same way from an `instance_type: small` step,
so the grant should follow whatever pattern covers that secret.

Until the grant lands, this step keeps failing on master postmerge
builds, now with a clear message. It doesn't block master. If the
release-candidate noise is a problem in the meantime, re-adding a
`disabled` tag to the step turns it off, as the step comment describes.

## Not a duplicate

No open PR touches the redirect apply step. This follows up on ray-project#66024
and ray-project#66427.

## Testing

- Pulled the command block out of the YAML, replaced `$$` with `$` as
Buildkite does, and ran the apply branch under `bash -elc` with a stub
`aws`:
- `AccessDeniedException`, exit 254: the step prints the new error and
exits 1 without calling `apply`.
  - Empty secret value: the step prints the new error and exits 1.
- Non-empty value: the token is exported and reaches `rtd-redirects
apply`.
- `pre-commit run --files .buildkite/doc.rayci.yml`: the generic
whitespace, end-of-file, and large-file hooks passed. No
language-specific hook applies to this file.
- No Buildkite run. The step is `skip-on-premerge`, so a PR build can't
exercise it. Its first real run is the next master postmerge build after
merge.

## AI assistance

AI assistance (Claude Code) prepared this change and ran the checks
above. The submitter reviews every changed line before merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

7 participants