[iris] Return raw memray .bin traces and enable native tracking#4415
[iris] Return raw memray .bin traces and enable native tracking#4415
Conversation
Add RAW format to MemoryProfile that returns the .bin trace file directly, skipping the server-side transform step. Users run any memray reporter locally (flamegraph, tree, stats, speedscope). Dashboard MEM button now downloads .bin by default. Also enables --native on all memray attach calls so C/Rust allocations (e.g. HuggingFace tokenizers) are visible.
|
Claude finished @rjpower's task in 1m 35s —— View job PR Review: [iris] Return raw memray .bin traces and enable native tracking
Clean, well-structured PR. The RAW format addition follows the existing pattern nicely, and the early-return approach in all three runtimes (docker, process, k8s) is the right way to skip the transform step. A few items to consider: Minor Issues
Looks Good
Overall this is a clean change. The stale docstring is the only thing I'd fix before merging. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 615f1db126
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cluster_pb2.MemoryProfile.FLAMEGRAPH: ("flamegraph", "html"), | ||
| cluster_pb2.MemoryProfile.TABLE: ("table", "txt"), | ||
| cluster_pb2.MemoryProfile.STATS: ("stats", "json"), | ||
| cluster_pb2.MemoryProfile.RAW: ("raw", "bin"), |
There was a problem hiding this comment.
Regenerate protobuf stubs before using MemoryProfile.RAW
This new enum reference is currently unusable because the generated bindings were not updated with the proto change: cluster_pb2.MemoryProfile in lib/iris/src/iris/rpc/cluster_pb2.py still has only FLAMEGRAPH, TABLE, and STATS. As a result, importing iris.cluster.runtime.profile now raises AttributeError: RAW, which breaks any path that imports runtime profiling (including controller/test startup). Please regenerate and commit the protobuf outputs alongside cluster.proto.
Useful? React with 👍 / 👎.
| function buildProfileType(profilerType: ProfilerType): Record<string, unknown> { | ||
| if (profilerType === 'cpu') return { cpu: { format: 'SPEEDSCOPE' } } | ||
| if (profilerType === 'memory') return { memory: { format: 'FLAMEGRAPH' } } | ||
| if (profilerType === 'memory') return { memory: { format: 'RAW' } } |
There was a problem hiding this comment.
Decode raw profile bytes before constructing download Blob
Changing memory profiling to RAW makes profileData a binary memray trace, but the download path still turns base64 into a JS string (atob) and then builds Blob([decoded]). That string is UTF-8 encoded by Blob, which corrupts non-ASCII bytes, so the downloaded .bin can be invalid for memray reporters. Convert base64 to a Uint8Array (or otherwise keep bytes binary-safe) before creating the Blob in this flow and the mirrored JobDetail handler.
Useful? React with 👍 / 👎.
|
@claude can you check this PR comment and make a fix PR as needed:
|
|
Claude finished @rjpower's task in 2m 44s —— View job • Fix binary-safe base64 decoding for RAW memray downloads
Summary: The Changes:
Testing: Pre-commit checks pass. No backend Python changes, so no pytest needed. |
Fix binary data corruption in memray .bin downloads. The download path used `atob()` → `Blob([string])`, which UTF-8 encodes the string and corrupts non-ASCII bytes. Now uses `Uint8Array` to preserve raw bytes. Followup to #4415.
Add RAW format to MemoryProfile that returns the .bin trace file directly, skipping the server-side transform step. Users run any memray reporter locally (flamegraph, tree, stats, speedscope). Dashboard MEM button now downloads .bin by default. Also enables --native on all memray attach calls so C/Rust allocations (e.g. HuggingFace tokenizers) are visible.
Fix binary data corruption in memray .bin downloads. The download path used `atob()` → `Blob([string])`, which UTF-8 encodes the string and corrupts non-ASCII bytes. Now uses `Uint8Array` to preserve raw bytes. Followup to #4415.
Add RAW format to MemoryProfile that returns the .bin trace file directly,
skipping the server-side transform step. Users run any memray reporter
locally (flamegraph, tree, stats, speedscope). Dashboard MEM button now
downloads .bin by default. Also enables --native on all memray attach
calls so C/Rust allocations (e.g. HuggingFace tokenizers) are visible.