Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce minimal WireSchema #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tigrannajaryan
Copy link
Collaborator

This decouples human-readable Schema that is in JSON
format from WireSchema that is serialized in binary
format for efficiency. WireSchema contains only the
information that is necessary for wire compatibility
checks.

Resolves #24
(Note that we still need struct names for checks).

Here are byte size comparisons between JSON and WIRE
for the Otel/TEF schema with "Metrics" root:

JSON:  2976, zstd:  760
WIRE:   115, zstd:  113

The following components were refactored to use WireSchema
instead of Schema:

  • Generated Reader/Writer
  • Encoder/Decoders
  • gRPC client/server

The Generator continues using JSON Schema as its input, however
it now generates a WireSchema to be used in the generated code.

This decouples human-readable Schema that is in JSON
format from WireSchema that is serialized in binary
format for efficiency. WireSchema contains only the
information that is necessary for wire compatibility
checks.

Resolves #24
(Note that we still need struct names for checks).

Here are byte size comparisons between JSON and WIRE
for the Otel/TEF schema with "Metrics" root:

```
JSON:  2976, zstd:  760
WIRE:   115, zstd:  113
```

The following components were refactored to use WireSchema
instead of Schema:
- Generated Reader/Writer
- Encoder/Decoders
- gRPC client/server

The Generator continues using JSON Schema as its input, however
it now generates a WireSchema to be used in the generated code.
@tigrannajaryan
Copy link
Collaborator Author

Github action shows benchmark differences, but locally I get parity (as expected, since nothing significant in serialization changed). Local results:

                                │    main     │              binary               │
                                │   sec/op    │   sec/op     vs base              │
SerializeNative/STEF/none-10      3.885m ± 8%   3.724m ± 9%       ~ (p=0.180 n=6)
DeserializeNative/STEF/none-10    1.740m ± 3%   1.709m ± 1%  -1.73% (p=0.002 n=6)
SerializeFromPdata/STEF/none-10   89.18m ± 4%   89.08m ± 5%       ~ (p=0.818 n=6)
DeserializeToPdata/STEF/none-10   22.74m ± 3%   22.73m ± 3%       ~ (p=1.000 n=6)
geomean                           10.82m        10.65m       -1.53%

                                │    main     │              binary               │
                                │  sec/point  │  sec/point   vs base              │
SerializeNative/STEF/none-10      58.10n ± 8%   55.70n ± 9%       ~ (p=0.180 n=6)
DeserializeNative/STEF/none-10    26.02n ± 3%   25.57n ± 1%  -1.73% (p=0.002 n=6)
SerializeFromPdata/STEF/none-10   1.334µ ± 4%   1.333µ ± 5%       ~ (p=0.729 n=6)
DeserializeToPdata/STEF/none-10   340.2n ± 3%   339.9n ± 3%       ~ (p=1.000 n=6)
geomean                           161.8n        159.4n       -1.52%

                                │     main     │               binary               │
                                │     B/op     │     B/op      vs base              │
SerializeNative/STEF/none-10      3.523Mi ± 0%   3.519Mi ± 0%  -0.09% (p=0.041 n=6)
DeserializeNative/STEF/none-10    844.2Ki ± 0%   836.2Ki ± 0%  -0.95% (p=0.002 n=6)
SerializeFromPdata/STEF/none-10   124.7Mi ± 0%   124.7Mi ± 0%       ~ (p=0.818 n=6)
DeserializeToPdata/STEF/none-10   29.82Mi ± 0%   29.81Mi ± 0%  -0.03% (p=0.002 n=6)
geomean                           10.19Mi        10.17Mi       -0.26%

                                │    main     │               binary               │
                                │  allocs/op  │  allocs/op   vs base               │
SerializeNative/STEF/none-10      2.776k ± 0%   2.773k ± 0%        ~ (p=0.058 n=6)
DeserializeNative/STEF/none-10    1.372k ± 0%   1.230k ± 0%  -10.35% (p=0.002 n=6)
SerializeFromPdata/STEF/none-10   256.3k ± 0%   256.4k ± 0%        ~ (p=0.937 n=6)
DeserializeToPdata/STEF/none-10   623.5k ± 0%   623.3k ± 0%   -0.02% (p=0.002 n=6)
geomean                           27.93k        27.17k        -2.72%

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.

Eliminate the need to have struct and multimap names on the wire schema
1 participant