Use compact oneof memory structure#418
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
Benchmark ResultBenchmark diff with base branchBenchmark result |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 36 changed files in this pull request and generated 2 comments.
Files not reviewed (29)
- examples/ints/internal/ints/record.go: Language not supported
- examples/jsonl/internal/jsonstef/jsonvalue.go: Language not supported
- examples/jsonl/internal/jsonstef/record.go: Language not supported
- examples/profile/internal/profile/function.go: Language not supported
- examples/profile/internal/profile/labelvalue.go: Language not supported
- examples/profile/internal/profile/line.go: Language not supported
- examples/profile/internal/profile/location.go: Language not supported
- examples/profile/internal/profile/mapping.go: Language not supported
- examples/profile/internal/profile/numvalue.go: Language not supported
- examples/profile/internal/profile/profilemetadata.go: Language not supported
- examples/profile/internal/profile/sample.go: Language not supported
- examples/profile/internal/profile/samplevalue.go: Language not supported
- examples/profile/internal/profile/samplevaluetype.go: Language not supported
- go/otel/otelstef/anyvalue.go: Language not supported
- go/otel/otelstef/envelope.go: Language not supported
- go/otel/otelstef/event.go: Language not supported
- go/otel/otelstef/exemplar.go: Language not supported
- go/otel/otelstef/exemplarvalue.go: Language not supported
- go/otel/otelstef/exphistogrambuckets.go: Language not supported
- go/otel/otelstef/exphistogramvalue.go: Language not supported
- go/otel/otelstef/histogramvalue.go: Language not supported
- go/otel/otelstef/link.go: Language not supported
- go/otel/otelstef/metric.go: Language not supported
- go/otel/otelstef/metrics.go: Language not supported
- go/otel/otelstef/point.go: Language not supported
- go/otel/otelstef/pointvalue.go: Language not supported
- go/otel/otelstef/quantilevalue.go: Language not supported
- go/otel/otelstef/resource.go: Language not supported
- go/otel/otelstef/scope.go: Language not supported
Comments suppressed due to low confidence (1)
stefc/templates/go/struct.go.tmpl:125
- The new exported Reset() forwards to reset(), but reset() does not clear
modifiedFields.mask(or nested modified state). After a struct has been used once, calling Reset() leaves prior modified bits set, so subsequent encoding/diff operations can behave as if fields are still modified even though values were cleared. Either have Reset() also clear modified flags (e.g., by calling setUnmodifiedRecursively()/setting modifiedFields.mask=0 after resetting children) or adjust the Reset doc to avoid claiming an "initial state" when modified flags are preserved.
e46b667 to
d510019
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 36 changed files in this pull request and generated 1 comment.
Files not reviewed (29)
- examples/ints/internal/ints/record.go: Language not supported
- examples/jsonl/internal/jsonstef/jsonvalue.go: Language not supported
- examples/jsonl/internal/jsonstef/record.go: Language not supported
- examples/profile/internal/profile/function.go: Language not supported
- examples/profile/internal/profile/labelvalue.go: Language not supported
- examples/profile/internal/profile/line.go: Language not supported
- examples/profile/internal/profile/location.go: Language not supported
- examples/profile/internal/profile/mapping.go: Language not supported
- examples/profile/internal/profile/numvalue.go: Language not supported
- examples/profile/internal/profile/profilemetadata.go: Language not supported
- examples/profile/internal/profile/sample.go: Language not supported
- examples/profile/internal/profile/samplevalue.go: Language not supported
- examples/profile/internal/profile/samplevaluetype.go: Language not supported
- go/otel/otelstef/anyvalue.go: Language not supported
- go/otel/otelstef/envelope.go: Language not supported
- go/otel/otelstef/event.go: Language not supported
- go/otel/otelstef/exemplar.go: Language not supported
- go/otel/otelstef/exemplarvalue.go: Language not supported
- go/otel/otelstef/exphistogrambuckets.go: Language not supported
- go/otel/otelstef/exphistogramvalue.go: Language not supported
- go/otel/otelstef/histogramvalue.go: Language not supported
- go/otel/otelstef/link.go: Language not supported
- go/otel/otelstef/metric.go: Language not supported
- go/otel/otelstef/metrics.go: Language not supported
- go/otel/otelstef/point.go: Language not supported
- go/otel/otelstef/pointvalue.go: Language not supported
- go/otel/otelstef/quantilevalue.go: Language not supported
- go/otel/otelstef/resource.go: Language not supported
- go/otel/otelstef/scope.go: Language not supported
Borrows the storage format idea from https://github.com/tigrannajaryan/govariant This reduces memory usage when multiple records are kept in memory and also improves speed of some operations. Benchmarking results: ``` goos: darwin goarch: arm64 pkg: github.com/splunk/stef/benchmarks cpu: Apple M2 Pro │ bench_base.txt │ bench_current.txt │ │ sec/op │ sec/op vs base │ SerializeNative/STEF/serialize-10 5.000m ± 4% 3.193m ± 3% -36.14% (p=0.000 n=18) DeserializeNative/STEF/deser-10 1.479m ± 7% 1.489m ± 5% ~ (p=0.839 n=18) SerializeFromPdata/STEF/serialize-10 70.37m ± 3% 58.67m ± 4% -16.63% (p=0.000 n=18) DeserializeToPdata/STEF/deserialize-10 24.92m ± 2% 24.89m ± 2% ~ (p=0.815 n=18) STEFReaderRead-10 1.523m ± 3% 1.495m ± 6% ~ (p=0.323 n=18) STEFSerializeMultipart/astronomy-otelmetrics-10 1.958 ± 3% 1.808 ± 3% -7.68% (p=0.000 n=18) STEFDeserializeMultipart/astronomy-otelmetrics-10 45.87m ± 3% 46.92m ± 6% ~ (p=0.143 n=18) ReadSTEF-10 1.695m ± 2% 1.655m ± 3% -2.35% (p=0.008 n=18) ReadSTEFZ-10 2.218m ± 2% 2.227m ± 3% ~ (p=0.988 n=18) ReadSTEFZWriteSTEF-10 4.682m ± 4% 4.735m ± 5% ~ (p=0.134 n=18) geomean 11.21m 10.44m -6.85% │ bench_base.txt │ bench_current.txt │ │ sec/point │ sec/point vs base │ SerializeNative/STEF/serialize-10 74.79n ± 4% 47.76n ± 3% -36.14% (p=0.000 n=18) DeserializeNative/STEF/deser-10 22.12n ± 7% 22.27n ± 5% ~ (p=0.833 n=18) SerializeFromPdata/STEF/serialize-10 1053.5n ± 3% 878.0n ± 4% -16.66% (p=0.000 n=18) DeserializeToPdata/STEF/deserialize-10 373.0n ± 2% 372.5n ± 2% ~ (p=0.784 n=18) STEFReaderRead-10 22.79n ± 3% 22.36n ± 6% ~ (p=0.319 n=18) STEFSerializeMultipart/astronomy-otelmetrics-10 2.489µ ± 3% 2.298µ ± 3% -7.68% (p=0.000 n=18) STEFDeserializeMultipart/astronomy-otelmetrics-10 58.30n ± 3% 59.63n ± 6% ~ (p=0.145 n=18) ReadSTEF-10 25.37n ± 2% 24.77n ± 3% -2.35% (p=0.008 n=18) ReadSTEFZ-10 33.19n ± 2% 33.33n ± 3% ~ (p=0.981 n=18) ReadSTEFZWriteSTEF-10 70.07n ± 4% 70.86n ± 5% ~ (p=0.132 n=18) geomean 102.4n 95.39n -6.85% │ bench_base.txt │ bench_current.txt │ │ B/op │ B/op vs base │ SerializeNative/STEF/serialize-10 3.373Mi ± 0% 3.395Mi ± 0% +0.63% (p=0.000 n=18) DeserializeNative/STEF/deser-10 951.4Ki ± 0% 725.8Ki ± 0% -23.71% (p=0.000 n=18) SerializeFromPdata/STEF/serialize-10 79.76Mi ± 0% 36.49Mi ± 0% -54.25% (p=0.000 n=18) DeserializeToPdata/STEF/deserialize-10 34.83Mi ± 0% 34.61Mi ± 0% -0.63% (p=0.000 n=18) STEFReaderRead-10 953.1Ki ± 0% 727.5Ki ± 0% -23.67% (p=0.000 n=18) STEFSerializeMultipart/astronomy-otelmetrics-10 4.868Gi ± 0% 4.168Gi ± 0% -14.37% (p=0.000 n=18) STEFDeserializeMultipart/astronomy-otelmetrics-10 20.30Mi ± 0% 20.19Mi ± 0% -0.56% (p=0.000 n=18) ReadSTEF-10 953.1Ki ± 0% 727.5Ki ± 0% -23.67% (p=0.000 n=18) ReadSTEFZ-10 10.29Mi ± 0% 10.07Mi ± 0% -2.14% (p=0.000 n=18) ReadSTEFZWriteSTEF-10 13.45Mi ± 0% 13.22Mi ± 0% -1.67% (p=0.000 n=18) geomean 12.66Mi 10.58Mi -16.41% │ bench_base.txt │ bench_current.txt │ │ allocs/op │ allocs/op vs base │ SerializeNative/STEF/serialize-10 2.642k ± 0% 2.662k ± 0% +0.76% (p=0.000 n=18) DeserializeNative/STEF/deser-10 463.0 ± 0% 464.0 ± 0% +0.22% (p=0.000 n=18) SerializeFromPdata/STEF/serialize-10 134.7k ± 0% 134.7k ± 0% +0.03% (p=0.021 n=18) DeserializeToPdata/STEF/deserialize-10 756.2k ± 0% 756.2k ± 0% +0.00% (p=0.000 n=18) STEFReaderRead-10 463.0 ± 0% 464.0 ± 0% +0.22% (p=0.000 n=18) STEFSerializeMultipart/astronomy-otelmetrics-10 13.15M ± 0% 13.22M ± 0% +0.51% (p=0.000 n=18) STEFDeserializeMultipart/astronomy-otelmetrics-10 1.958k ± 0% 7.923k ± 0% +304.65% (p=0.000 n=18) ReadSTEF-10 463.0 ± 0% 464.0 ± 0% +0.22% (p=0.000 n=18) ReadSTEFZ-10 503.0 ± 0% 504.0 ± 0% +0.20% (p=0.000 n=18) ReadSTEFZWriteSTEF-10 1.230k ± 0% 1.232k ± 0% +0.16% (p=0.000 n=18) geomean 7.293k 8.406k +15.27% ``` Also added a benchmarks that reads many records at once to show how much memory is reduced: ``` goos: darwin goarch: arm64 pkg: github.com/splunk/stef/benchmarks cpu: Apple M2 Pro │ main.txt │ after.txt │ │ sec/op │ sec/op vs base │ ReaderReadMany-10 12.087m ± 5% 9.782m ± 2% -19.07% (p=0.002 n=6) │ main.txt │ after.txt │ │ sec/point │ sec/point vs base │ ReaderReadMany-10 181.0n ± 5% 146.5n ± 2% -19.06% (p=0.002 n=6) │ main.txt │ after.txt │ │ B/op │ B/op vs base │ ReaderReadMany-10 2111.4Ki ± 6% 921.2Ki ± 1% -56.37% (p=0.002 n=6) │ main.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ ReaderReadMany-10 970.0 ± 5% 845.5 ± 2% -12.84% (p=0.002 n=6) ```
d510019 to
af8261b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 36 changed files in this pull request and generated no new comments.
Files not reviewed (29)
- examples/ints/internal/ints/record.go: Language not supported
- examples/jsonl/internal/jsonstef/jsonvalue.go: Language not supported
- examples/jsonl/internal/jsonstef/record.go: Language not supported
- examples/profile/internal/profile/function.go: Language not supported
- examples/profile/internal/profile/labelvalue.go: Language not supported
- examples/profile/internal/profile/line.go: Language not supported
- examples/profile/internal/profile/location.go: Language not supported
- examples/profile/internal/profile/mapping.go: Language not supported
- examples/profile/internal/profile/numvalue.go: Language not supported
- examples/profile/internal/profile/profilemetadata.go: Language not supported
- examples/profile/internal/profile/sample.go: Language not supported
- examples/profile/internal/profile/samplevalue.go: Language not supported
- examples/profile/internal/profile/samplevaluetype.go: Language not supported
- go/otel/otelstef/anyvalue.go: Language not supported
- go/otel/otelstef/envelope.go: Language not supported
- go/otel/otelstef/event.go: Language not supported
- go/otel/otelstef/exemplar.go: Language not supported
- go/otel/otelstef/exemplarvalue.go: Language not supported
- go/otel/otelstef/exphistogrambuckets.go: Language not supported
- go/otel/otelstef/exphistogramvalue.go: Language not supported
- go/otel/otelstef/histogramvalue.go: Language not supported
- go/otel/otelstef/link.go: Language not supported
- go/otel/otelstef/metric.go: Language not supported
- go/otel/otelstef/metrics.go: Language not supported
- go/otel/otelstef/point.go: Language not supported
- go/otel/otelstef/pointvalue.go: Language not supported
- go/otel/otelstef/quantilevalue.go: Language not supported
- go/otel/otelstef/resource.go: Language not supported
- go/otel/otelstef/scope.go: Language not supported
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.
Borrows the storage format idea from https://github.com/tigrannajaryan/govariant This reduces memory usage when multiple records are kept in memory and also improves speed of some operations.
Benchmarking results:
Also added a benchmarks that reads many records at once to show how much memory is reduced: