[VL] Refactor Velox metrics transport to use JSON payloads#12126
Merged
Conversation
8755a20 to
f05b72a
Compare
465e90e to
a5fa3be
Compare
a5fa3be to
fbf2b67
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Velox backend’s metrics transport across the JNI boundary from large long[] arrays to a structured JSON payload, shifting most metric-field mapping and interpretation logic into Scala for better extensibility and stability.
Changes:
- Replace JNI long-array metrics plumbing with a JSON payload (
metricsJson) plus metadata (numMetrics,veloxToArrow,taskStats). - Serialize ordered Velox plan/operator stats to JSON in native code and decode/flatten into
OperatorMetricson the Scala side. - Add developer documentation describing the end-to-end Velox→Spark metrics mapping workflow.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mkdocs.yml | Adds the new Metrics Framework doc to the developer navigation. |
| docs/developers/MetricsFramework.md | Documents the ordered-node + JSON + Spark-updater-tree mapping contract. |
| cpp/velox/tests/RuntimeTest.cc | Updates dummy metrics construction to the new JSON-based API. |
| cpp/velox/compute/WholeStageResultIterator.h | Removes the old runtime-metric helper declaration no longer needed with JSON transport. |
| cpp/velox/compute/WholeStageResultIterator.cc | Serializes Velox plan/task stats into a JSON payload and constructs Metrics(numMetrics, json). |
| cpp/core/utils/Metrics.h | Refactors native Metrics to carry json (and optional stats) instead of a typed long-array buffer. |
| cpp/core/jni/JniWrapper.cc | Updates org.apache.gluten.metrics.Metrics JNI constructor signature and passes JSON + metadata. |
| backends-velox/src/main/scala/org/apache/gluten/metrics/MetricsUtil.scala | Adds JSON parsing + flattening to OperatorMetrics and updates the updater traversal to consume flattened suites. |
| backends-velox/src/main/java/org/apache/gluten/metrics/OperatorMetrics.java | Adds a no-arg constructor for placeholder/empty metrics suites. |
| backends-velox/src/main/java/org/apache/gluten/metrics/Metrics.java | Replaces the wide long-array-based representation with metricsJson, numMetrics, and SingleMetric. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+132
to
+136
| val loadLazyVectorMetricsIdx = orderedNodeIds.size() - 1 | ||
| if (loadLazyVectorMetricsIdx >= 0 && loadLazyVectorMetricsIdx < operatorMetrics.size()) { | ||
| operatorMetrics.get(loadLazyVectorMetricsIdx).loadLazyVectorTime = | ||
| root.path("loadLazyVectorTime").asLong(0L) | ||
| } |
Member
|
related: #12127 |
fbf2b67 to
2f70973
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Refactors Velox metrics transport away from fragile JNI long-array plumbing to a structured JSON payload decoded on the Scala side.
Replace the long Metrics JNI constructor with a stable metricsJson, numMetrics, veloxToArrow, and taskStats payload.
Move native metric field mapping and custom runtime metric extraction into MetricsUtil.scala.
Making future metric additions mostly Scala-side changes.
Keep C++ responsible only for exporting ordered Velox operator stats and task stats metadata.
Adds MetricsFramework.md documentation.
How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?