refactor: replace proto serialization with JSON and migrate callsites#222
Open
yushan8 wants to merge 5 commits into
Open
refactor: replace proto serialization with JSON and migrate callsites#222yushan8 wants to merge 5 commits into
yushan8 wants to merge 5 commits into
Conversation
This was referenced Jul 20, 2026
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 03:42
6fc3266 to
0f5a89c
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
2 times, most recently
from
July 20, 2026 03:46
1a54757 to
2252f29
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
2 times, most recently
from
July 20, 2026 04:52
5fb83ae to
7f55e85
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
2 times, most recently
from
July 20, 2026 05:27
8677311 to
614cddf
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 05:27
7f55e85 to
e762db8
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
2 times, most recently
from
July 20, 2026 17:17
dff47a4 to
9c060bc
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 20, 2026 17:27
7ec0e66 to
2870453
Compare
yushan8
added a commit
that referenced
this pull request
Jul 20, 2026
…210) ## Summary - Add `entity.OptimizedTarget`, `entity.Metadata`, and `entity.GetTargetGraphResponse` as compact, proto-free representations of the target graph wire types - Add `entity.ChangedTarget` and `entity.GetChangedTargetsResponse` for the changed-targets path - These entity types mirror the proto definitions but live in a dependency-free package, preventing proto from leaking into storage, orchestrator, and other non-transport layers ## Test plan - [x] `make build && make test && make gazelle` ## Stack 1. **#210 — this PR** (entity types) 2. #211 (mappers + streaming) 3. #222 (storage JSON rewrite) 4. #212 (callsite migration + cleanup) --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 task
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 18:21
9c060bc to
63d2138
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
2 times, most recently
from
July 20, 2026 18:33
140a936 to
1f1b327
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 18:41
63d2138 to
7b87081
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 20, 2026 18:42
1f1b327 to
6d0f3a7
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 19:32
7b87081 to
23bf3ac
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
3 times, most recently
from
July 20, 2026 21:47
e57a2e1 to
1f8366f
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 22:09
e762709 to
8f360d1
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 20, 2026 22:13
1f8366f to
e9517ce
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 22:20
8f360d1 to
15fe2f7
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 20, 2026 22:21
e9517ce to
af13970
Compare
yushan8
force-pushed
the
yushan/streaming-and-mappers
branch
from
July 20, 2026 22:32
15fe2f7 to
814e971
Compare
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 20, 2026 22:34
af13970 to
cb19db6
Compare
yushan8
added a commit
that referenced
this pull request
Jul 20, 2026
## Summary - Adds entity-proto mappers for target graph and changed targets responses - `ResultToTargetGraph` — converts `targethasher.Result` into ID-mapped entity types - `GetTargetGraphResponseToProto` / `ChangedTargetsResponseToProto` — entity→proto conversions for gRPC streaming - `ProtoToGetTargetGraphRequest` — proto→entity request conversion This PR is addresses this comment to split up the Result -> Optimized target entity conversion, and OptimizedTarget -> `GetTargetGraphResponseToProto` #206. These mappers are used to avoid leaking proto definitions into internals such as storage and orchestrator. ## Stack 1. #224 (streaming split utilities) 2. **This PR** (entity-proto mappers) 3. #222 (storage JSON rewrite) 4. #212 (callsite migration) ## Test plan - [x] `make build && make test && make gazelle` --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Base automatically changed from
yushan/streaming-and-mappers
to
yushan/streaming-split
July 20, 2026 23:36
xytan0056
reviewed
Jul 21, 2026
| } | ||
| // defaultMaxMessageBytes is the fallback max serialized size per streamed | ||
| // message (~4.25 MB), well under the 64 MB default gRPC limit. | ||
| const defaultMaxMessageBytes = 4_250_000 |
Contributor
There was a problem hiding this comment.
can this be exported? Multiple palces are referencing it
xytan0056
reviewed
Jul 21, 2026
| @@ -1,4 +1,4 @@ | |||
| // Copyright (c) 2026 Uber Technologies, Inc. | |||
| // Copyright (c) 2025 Uber Technologies, Inc. | |||
xytan0056
reviewed
Jul 21, 2026
Contributor
There was a problem hiding this comment.
now we have internal/mapper and mapper. How about optimized?
xytan0056
reviewed
Jul 21, 2026
| tempResp := mapper.ChangedTargetsResponseToProto(&entity.GetChangedTargetsResponse{ChangedTargets: changed}) | ||
| protoChanged := tempResp.GetItem().(*pb.GetChangedTargetsResponse_ChangedTargets).ChangedTargets.GetChangedTargets() | ||
| var results []entity.GetChangedTargetsResponse | ||
| changedGroups, err := streaming.SplitBySize(protoChanged, c.maxMessageBytes) |
Contributor
There was a problem hiding this comment.
where is streaming.SplitBySize defined? I can't find it
looks like we called ChangedTargetsResponseToProto twice here , once for splitting, once for sending later
xytan0056
reviewed
Jul 21, 2026
| results = append(results, entity.GetChangedTargetsResponse{ | ||
| ChangedTargets: changed[idx : idx+len(group)], | ||
| }) | ||
| idx += len(group) |
Contributor
There was a problem hiding this comment.
actually looks like the whole ChangedTargetsResponseToProto -> protoChanged => SplitBySize -> changedGroups is just for len(group) ? seems too expensive, can we feed something to SplitBysize without the conversion?
yushan8
added a commit
that referenced
this pull request
Jul 21, 2026
- Export DefaultMaxMessageBytes in config package and use it from controller instead of hardcoded value - Update copyright year to 2026 in core/storage/reader.go - Add Size() to entity.ChangedTarget and inline size-based splitting in compareTargetGraphs, eliminating the wasteful proto conversion that was only used for size measurement - Add ProtoToChangedTargetsResponse mapper for cache read boundary Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Remove all proto from core/storage, replacing with encoding/json. Migrate controller and orchestrator to entity types, converting to proto only at the gRPC boundary. Consolidate chunking config into max_message_bytes. Remove old chunking code from core/common. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ation Update toChangeType to return entity.ChangeType, mapper to cast via int32, and test assertions to use entity constants. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Run gazelle to remove stale //config and //core/common deps from controller BUILD.bazel. Replace context.Background() with t.Context() in test helper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Remove _defaultMaxMessageBytes constant and inline the value with a TODO to provide it via config.Parse. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Export DefaultMaxMessageBytes in config package and use it from controller instead of hardcoded value - Update copyright year to 2026 in core/storage/reader.go - Add Size() to entity.ChangedTarget and inline size-based splitting in compareTargetGraphs, eliminating the wasteful proto conversion that was only used for size measurement - Add ProtoToChangedTargetsResponse mapper for cache read boundary Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
yushan8
force-pushed
the
yushan/storage-json
branch
from
July 21, 2026 04:39
28a89e0 to
4860e6e
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.
Summary
core/storage/— serialize entity structs directly viaencoding/jsongraphwriter.goentity.GetTargetGraphResponseandentity.GetChangedTargetsResponseinternally, converting to proto via mapper only atstream.Sendmapper.ResultToTargetGraph+mapper.ChunkTargetGraphservice.chunking.*into a singleservice.max_message_bytesconfig fieldcore/commonquery-benchexampleTest plan
grep -r "tangopb\|gogo/protobuf" core/storage/returns zero resultsmake build && make test— all 19 test targets passmake gazelle— BUILD files in syncStack