perf: replace protobuf metric reporting with pre-allocated flat long[] array#3614
Open
andygrove wants to merge 4 commits intoapache:mainfrom
Open
perf: replace protobuf metric reporting with pre-allocated flat long[] array#3614andygrove wants to merge 4 commits intoapache:mainfrom
andygrove wants to merge 4 commits intoapache:mainfrom
Conversation
…] array Replace the protobuf-based metric update path with a flat array approach for significantly faster metric transfers from native to JVM. Previously, every metric update built a HashMap<String, i64> and NativeMetricNode protobuf tree, encoded it, decoded on JVM side, then walked the tree with Map.get() lookups per metric. Now, metrics are flattened into parallel arrays at plan creation time, native fills a Vec<i64> and copies to JVM via a single SetLongArrayRegion bulk JNI call, and JVM reads linearly — no protobuf, no tree walking, no map lookups, no string allocations per update cycle.
Metrics like conversionTime are accumulated on the JVM side and have no native counterpart. Initialize the values array to -1 (sentinel) and only update SQLMetrics where native actually wrote a value (>= 0), preventing native metric updates from zeroing out JVM-accumulated metrics.
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.
Which issue does this PR close?
N/A
Rationale for this change
I have been profiling with async-profiler and saw a surprising amount of time spent in metrics handling.
What changes are included in this PR?
long[]array approach for faster native-to-JVM metric transferCometMetricNodetreeVec<i64>and copies to JVM via singleSetLongArrayRegionbulk JNI call instead of protobuf encode/decodemetric.protoand all protobuf metric infrastructureHow are these changes tested?