Skip to content

Emit Quent events for cudf-polars memory reservation. - #24038

Draft
TomAugspurger wants to merge 1 commit into
NVIDIA:mainfrom
TomAugspurger:tom/quent-resources+memory-reservation
Draft

Emit Quent events for cudf-polars memory reservation.#24038
TomAugspurger wants to merge 1 commit into
NVIDIA:mainfrom
TomAugspurger:tom/quent-resources+memory-reservation

Conversation

@TomAugspurger

Copy link
Copy Markdown
Contributor

Description

This updates our emitted Quent telemetry to better track memory reservations. I've added a wrapper around rapidsmpf.streaming.core.memory_reserve_or_wait.reserve_memory that includes

  • the reservation size
  • the memory tier
  • the net memory delta
  • the sequence number

Like any other Quent event, this can be tied back to an individual Operator (cudf-polars Actor).

@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Sep 8, 2026
Comment on lines +524 to +525
They're all built after the fact from recorded timestamps, so emitting
them doesn't inflate the wait we're trying to measure.

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.

remove.

Comment on lines +527 to +528
A reservation that induces spilling ought to pass through the Task's
``Spilling`` state, but rapidsmpf doesn't report that back to us yet.

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.

Remove this too. I'll have a longer issue about tracking spilled operations.

This emits the following events:

- queueing
- allocating (with the Quent Processor for the current thread)

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.

Just a note: making a memory reservation is async in python, so this will to be running on the asyncio event loop, concurrently with many other things. I think this is the right way to model this in Quent, but we'll want to double check that. We aren't really consuming CPU resources to run this task.

``Spilling`` state, but rapidsmpf doesn't report that back to us yet.
"""
quent_processor = quent_ir_execution_context.get_or_declare_processor(
thread_ident=threading.get_ident(),

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.

Maybe this should be a parameter? We're doing this at emit time, which in theory could be running on a different thread than the one that requested the memory reservation. But currently that's not an issue since we always create the reservation and then emit the events.

Comment on lines +884 to +891
def _format_bytes(nbytes: int) -> str:
"""Format a byte count compactly (e.g. ``256.0MiB``) for display."""
value = float(nbytes)
for unit in ("B", "KiB", "MiB", "GiB", "TiB"):
if abs(value) < 1024.0:
return f"{value:.0f}B" if unit == "B" else f"{value:.1f}{unit}"
value /= 1024.0
return f"{value:.1f}PiB"

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 probably isn't necessary. I don't think the size of the reservation should appear in the label...

Comment on lines +906 to +908
purpose
What the memory is reserved for (e.g. ``"scan"``). Distinguishes
reservations made by a single operator.

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'd like to understand this better: what operators make multiple reservations?

Requiring this might not be smart. Then we'll end up with redundant info in the telemetry like "The Scan operator reserved memory for a scan."

And perhaps this could be an enum rather than an arbitrary string, to make things easier for consumers of the output.

Comment on lines +931 to +935

Quent's data processing domain doesn't declare attributes on the
``Allocating`` state yet, so an analyzer built against the current model
reads the timing but ignores the attributes below. They're still written
to the event stream, and will show up once the model declares them.

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.

Remove this.

def label(self) -> str:
"""A compact description, e.g. ``scan-256.0MiB-device``."""
return (
f"{self.purpose}-{_format_bytes(self.size_bytes)}-{self.mem_type.lower()}"

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.

Remove the size from the label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars Python Affects Python cuDF API.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant