Skip to content

[Core] Compute per component memory usage in MiB (#63932) - #64042

Merged
edoakes merged 1 commit into
ray-project:releases/2.56.0from
edoakes:eoakes/cp-mem
Jun 11, 2026
Merged

edoakes merged 1 commit into
ray-project:releases/2.56.0from
edoakes:eoakes/cp-mem

Conversation

@edoakes

@edoakes edoakes commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick #63932

We have observed that the idle worker memory usage as reported in the
per component memory usage metric grows over time. Previous
investigation has concluded that it's possible for idle workers to
"leak" memory due to imported libraries caching memory regions between
tasks, resulting in a large idle worker footprint between runs. We have
also previously uncovered that memory leaks in popular libraries can
also result in idle worker memory growth:
apache/arrow#39808.

However a recent investigation into the trivial workload below with no
library usage still showed idle worker memory growth over time.
```py
import ray
from tqdm import tqdm
import time

ray.init()

@ray.remote
def produce():
    a = b"0" * int(0.5 * 1024**3)
    time.sleep(5)
    return a

@ray.remote
def consume(bytes):
    time.sleep(5)
    return "done"

refs = []
for _ in tqdm(range(16)):
    ref = produce.remote()
    refs.append(ref)
    consume_refs = []
    for i in range(4):
        consume_refs.append(consume.remote(ref))
    print(ray.get(consume_refs))
```
Per component metric showing idle worker memory growth:
<img width="1687" height="398" alt="image"
src="https://github.com/user-attachments/assets/a8201713-d64a-44ff-bfd3-d9e070dd88b3"
/>

This growth is attributed to how "unique set size" is calculated in the
query for per component memory usage metric. Previously, we computed the
unique set size via the following query:
```
(sum(ray_component_rss_mb{instance=~".+",SessionName=~".+",ray_io_cluster=~".*",ClusterId=~"ID"} * 1024 * 1024) by (Component)) - (sum(ray_component_mem_shared_bytes{instance=~".+",SessionName=~".+",ray_io_cluster=~".*",ClusterId=~"ID"}) by (Component))
```
The problematic part is the `* 1024 * 1024` which attempts to convert
the rss back into bytes. However, the RSS was actually recorded in
megabytes instead mebibytes, resulting in over calculation. As the RSS
for the worker grows, this calculation grows increasingly incorrect as
shown by the graph below where we demonstrate the difference between
computing `pre-existing query (were we incorrectly convert megabytes
into bytes)` and the actual `unique set size`.
<img width="1189" height="590" alt="image"
src="https://github.com/user-attachments/assets/5537ac8a-efb2-4160-926c-9259540e135b"
/>

This PR addresses this mis-conversion by establishing bytes as the unit
for all per component memory metrics. The updated graph of idle worker
memory usage in the per component memory usage panel is shown below:
<img width="1689" height="398" alt="image"
src="https://github.com/user-attachments/assets/09437ccd-b7a3-43f4-a7cc-7a430710164e"
/>


---------

Signed-off-by: davik <[email protected]>
Co-authored-by: davik <[email protected]>
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Jun 11, 2026
@edoakes
edoakes requested review from a team as code owners June 11, 2026 22:05

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces new byte-based system metrics (ray_component_rss_bytes, ray_component_uss_bytes, and ray_component_shared_bytes) to replace the deprecated megabyte-based metrics, updating the documentation, dashboard, reporter agent, and tests accordingly. Feedback suggests optimizing dictionary lookups for memory_full_info in head.py and ensuring that component_rss_mb is reset to 0.0 in _generate_reseted_stats_record for consistency with the new byte-based metrics.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/ray/dashboard/head.py Resolved
@edoakes
edoakes merged commit f211d8a into ray-project:releases/2.56.0 Jun 11, 2026
3 checks passed
elliot-barn pushed a commit that referenced this pull request Jun 25, 2026
…dge cases (#64354)

## Description

The `get_contributors` release-notes script extracts PR numbers from
commit subjects to look up contributor logins. The old `_find_pr_number`
helper grabbed all text between `(#` and the first `)`, which produced
wrong results for several real commit titles:

- A truncated revert like `Revert "... hot path (#6... (#64309)` yielded
`6... (#64309` instead of `64309`.
- A title carrying a fixed-issue reference followed by the merging PR,
e.g. `... cpu_percent (#63729) (#63733)`, yielded the issue number
`63729` instead of the PR `63733`.
- **Cherry-picks** such as `... in MiB (#63932) (#64042)` (original PR +
backport PR) credited only one number, silently dropping the original
author.

This PR replaces it with `_find_pr_numbers`, which:

- Matches only well-formed `(#<digits>)` tokens using a module-level
compiled regex (the helper runs up to thousands of times per
invocation).
- Returns **every** candidate in title order. The commit text alone
cannot tell an issue from a PR or an original from a backport, so `run`
queries all candidates via the GitHub API and credits each one that
resolves as a real PR. A cherry-pick now credits both the original
author and the backporter.
- Treats a `404` as expected (the number is an issue, not a PR) and
collects those numbers, printing them at the end. This way, if GitHub's
behavior ever changes and a real PR starts returning `404`, the dropped
numbers are surfaced rather than silently lost.

## Related issues

N/A

## Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR,
cherry-pick, non-digit parentheticals) and the CLI behavior (both
cherry-pick authors credited; an issue `404` does not drop the real PR
author and is reported in the output).

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

---------

Signed-off-by: sai.miduthuri <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
limarkdcunha pushed a commit to limarkdcunha/ray that referenced this pull request Jun 30, 2026
…dge cases (ray-project#64354)

## Description

The `get_contributors` release-notes script extracts PR numbers from
commit subjects to look up contributor logins. The old `_find_pr_number`
helper grabbed all text between `(#` and the first `)`, which produced
wrong results for several real commit titles:

- A truncated revert like `Revert "... hot path (ray-project#6... (ray-project#64309)` yielded
`6... (ray-project#64309` instead of `64309`.
- A title carrying a fixed-issue reference followed by the merging PR,
e.g. `... cpu_percent (ray-project#63729) (ray-project#63733)`, yielded the issue number
`63729` instead of the PR `63733`.
- **Cherry-picks** such as `... in MiB (ray-project#63932) (ray-project#64042)` (original PR +
backport PR) credited only one number, silently dropping the original
author.

This PR replaces it with `_find_pr_numbers`, which:

- Matches only well-formed `(#<digits>)` tokens using a module-level
compiled regex (the helper runs up to thousands of times per
invocation).
- Returns **every** candidate in title order. The commit text alone
cannot tell an issue from a PR or an original from a backport, so `run`
queries all candidates via the GitHub API and credits each one that
resolves as a real PR. A cherry-pick now credits both the original
author and the backporter.
- Treats a `404` as expected (the number is an issue, not a PR) and
collects those numbers, printing them at the end. This way, if GitHub's
behavior ever changes and a real PR starts returning `404`, the dropped
numbers are surfaced rather than silently lost.

## Related issues

N/A

## Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR,
cherry-pick, non-digit parentheticals) and the CLI behavior (both
cherry-pick authors credited; an issue `404` does not drop the real PR
author and is reported in the output).

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

---------

Signed-off-by: sai.miduthuri <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…dge cases (ray-project#64354)

## Description

The `get_contributors` release-notes script extracts PR numbers from
commit subjects to look up contributor logins. The old `_find_pr_number`
helper grabbed all text between `(#` and the first `)`, which produced
wrong results for several real commit titles:

- A truncated revert like `Revert "... hot path (ray-project#6... (ray-project#64309)` yielded
`6... (ray-project#64309` instead of `64309`.
- A title carrying a fixed-issue reference followed by the merging PR,
e.g. `... cpu_percent (ray-project#63729) (ray-project#63733)`, yielded the issue number
`63729` instead of the PR `63733`.
- **Cherry-picks** such as `... in MiB (ray-project#63932) (ray-project#64042)` (original PR +
backport PR) credited only one number, silently dropping the original
author.

This PR replaces it with `_find_pr_numbers`, which:

- Matches only well-formed `(#<digits>)` tokens using a module-level
compiled regex (the helper runs up to thousands of times per
invocation).
- Returns **every** candidate in title order. The commit text alone
cannot tell an issue from a PR or an original from a backport, so `run`
queries all candidates via the GitHub API and credits each one that
resolves as a real PR. A cherry-pick now credits both the original
author and the backporter.
- Treats a `404` as expected (the number is an issue, not a PR) and
collects those numbers, printing them at the end. This way, if GitHub's
behavior ever changes and a real PR starts returning `404`, the dropped
numbers are surfaced rather than silently lost.

## Related issues

N/A

## Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR,
cherry-pick, non-digit parentheticals) and the CLI behavior (both
cherry-pick authors credited; an issue `404` does not drop the real PR
author and is reported in the output).

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

---------

Signed-off-by: sai.miduthuri <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants