Skip to content

perf(grpc): avoid response JSON round-trip - #6259

Open
perfloop-agent wants to merge 2 commits into
grafana:masterfrom
perfloop:perfloop-pr-open-4aesba2ndd
Open

perf(grpc): avoid response JSON round-trip#6259
perfloop-agent wants to merge 2 commits into
grafana:masterfrom
perfloop:perfloop-pr-open-4aesba2ndd

Conversation

@perfloop-agent

@perfloop-agent perfloop-agent commented Aug 7, 2026

Copy link
Copy Markdown

What?

Replace the JSON byte round-trip for non-discarded unary gRPC responses with direct conversion from dynamic protobuf reflection into the concrete values Sobek exposes to JavaScript.

Keep the protojson conversion as a fallback for malformed or unsupported messages, retain EmitUnpopulated semantics, and add differential parity coverage. The converter documents the protojson behavior it mirrors and why field ordering is required for colliding JSON names.

Why?

Sobek needs concrete map-like values for response property access, so response materialization remains necessary. This removes only the temporary JSON encoding and decoding for supported response messages. DiscardResponseMessage and fallback behavior remain unchanged.

Testing

  • go test -race ./internal/lib/netext/grpcext
  • go test -race ./internal/js/modules/k6/grpc
  • golangci-lint run --new-from-rev=53b5727d893d30a5c73e5b1a9891283786e0ec44 ./internal/lib/netext/grpcext/... ./internal/js/modules/k6/grpc/...
  • Differential conversion and fallback-error tests cover protobuf JSON mapping and unsupported inputs.

On workload 16 KiB unary gRPC response through Client.Invoke, median ns/op moved from 335295 to 113728 (66.1% lower).

On workload 16 KiB unary gRPC response through Client.Invoke, median B/op moved from 135523 to 84563 (37.6% lower).

On workload 16 KiB unary gRPC response through Client.Invoke, median allocs/op moved from 301 to 277 (8% lower).
All 3 declared correctness checks passed.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Not applicable: this is an internal implementation change with no user-facing API or documentation update.

Related PR(s)/Issue(s)

None.


Authored and verified by Perfloop: every claim above was co-measured on both trees and independently re-verified before submission — the full record is public: case_0ba99ytksb. Replies from this account are human-approved, and a human operator is accountable for this contribution.

@perfloop-agent
perfloop-agent requested a review from a team as a code owner August 7, 2026 01:53
@perfloop-agent
perfloop-agent requested review from inancgumus and janHildebrandt98 and removed request for a team August 7, 2026 01:53
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Signed commits report

2 of 2 commits between master and perfloop-pr-open-4aesba2ndd could not be fully verified:

Commit Author Reason Message
057a6951 Perfloop Agent unsigned test(grpc): cover and benchmark response conversion
29de1a30 Perfloop Agent unsigned perf(grpc): convert dynamic responses directly

This repository requires all commits to be signed. See GitHub docs on commit signature verification.

@cla-assistant

cla-assistant Bot commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@perfloop-agent
perfloop-agent force-pushed the perfloop-pr-open-4aesba2ndd branch from 60a3bc5 to 29de1a3 Compare August 8, 2026 00:41
@perfloop-agent perfloop-agent changed the title perf(grpc): avoid JSON round-trip for dynamic responses perf(grpc): avoid response JSON round-trip Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant