Skip to content

Commit e004ecd

Browse files
authored
Faster json parser (#33785)
**Description:** Switch libraries to reduce the footprint of the JSON parser. **Link to tracking Issue:** Fixes #33784 **Testing:** Before: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/json BenchmarkProcess-10 49047 23951 ns/op 26277 B/op 177 allocs/op BenchmarkProcess-10 50248 24002 ns/op 26275 B/op 177 allocs/op BenchmarkProcess-10 50258 24517 ns/op 26276 B/op 177 allocs/op BenchmarkProcess-10 50505 24731 ns/op 26276 B/op 177 allocs/op BenchmarkProcess-10 45708 24730 ns/op 26276 B/op 177 allocs/op BenchmarkProcess-10 50022 25021 ns/op 26277 B/op 177 allocs/op BenchmarkProcess-10 47204 24794 ns/op 26275 B/op 177 allocs/op BenchmarkProcess-10 47742 25335 ns/op 26274 B/op 177 allocs/op BenchmarkProcess-10 46252 25205 ns/op 26276 B/op 177 allocs/op BenchmarkProcess-10 47916 24379 ns/op 26277 B/op 177 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/json 15.559s ``` After: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/json BenchmarkProcess-10 95613 12168 ns/op 14702 B/op 115 allocs/op BenchmarkProcess-10 97904 12343 ns/op 14704 B/op 115 allocs/op BenchmarkProcess-10 99006 12187 ns/op 14702 B/op 115 allocs/op BenchmarkProcess-10 96964 12310 ns/op 14703 B/op 115 allocs/op BenchmarkProcess-10 98661 12285 ns/op 14703 B/op 115 allocs/op BenchmarkProcess-10 96896 12356 ns/op 14703 B/op 115 allocs/op BenchmarkProcess-10 94118 12367 ns/op 14703 B/op 115 allocs/op BenchmarkProcess-10 96123 12349 ns/op 14702 B/op 115 allocs/op BenchmarkProcess-10 96948 12305 ns/op 14702 B/op 115 allocs/op BenchmarkProcess-10 96626 12225 ns/op 14702 B/op 115 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/json 13.619s ``` Benchstat: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/json │ before.txt │ after.txt │ │ sec/op │ sec/op vs base │ Process-10 24.73µ ± 3% 12.31µ ± 1% -50.23% (p=0.000 n=10) │ before.txt │ after.txt │ │ B/op │ B/op vs base │ Process-10 25.66Ki ± 0% 14.36Ki ± 0% -44.05% (p=0.000 n=10) │ before.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ Process-10 177.0 ± 0% 115.0 ± 0% -35.03% (p=0.000 n=10) ```
1 parent 450b088 commit e004ecd

File tree

45 files changed

+157
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+157
-21
lines changed

.chloggen/faster_json_parser.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Switch JSON parser used by json_parser to github.com/goccy/go-json
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [33784]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

cmd/otelcontribcol/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ require (
483483
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
484484
github.com/go-zookeeper/zk v1.0.3 // indirect
485485
github.com/gobwas/glob v0.2.3 // indirect
486-
github.com/goccy/go-json v0.10.2 // indirect
486+
github.com/goccy/go-json v0.10.3 // indirect
487487
github.com/gocql/gocql v1.6.0 // indirect
488488
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
489489
github.com/godbus/dbus/v5 v5.0.6 // indirect

cmd/otelcontribcol/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/oteltestbedcol/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ require (
107107
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
108108
github.com/go-zookeeper/zk v1.0.3 // indirect
109109
github.com/gobwas/glob v0.2.3 // indirect
110+
github.com/goccy/go-json v0.10.3 // indirect
110111
github.com/gogo/googleapis v1.4.1 // indirect
111112
github.com/gogo/protobuf v1.3.2 // indirect
112113
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect

cmd/oteltestbedcol/go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connector/datadogconnector/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ require (
126126
github.com/go-openapi/swag v0.22.9 // indirect
127127
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
128128
github.com/gobwas/glob v0.2.3 // indirect
129-
github.com/goccy/go-json v0.10.2 // indirect
129+
github.com/goccy/go-json v0.10.3 // indirect
130130
github.com/godbus/dbus/v5 v5.0.6 // indirect
131131
github.com/gogo/protobuf v1.3.2 // indirect
132132
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect

connector/datadogconnector/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporter/datadogexporter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ require (
175175
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
176176
github.com/go-zookeeper/zk v1.0.3 // indirect
177177
github.com/gobwas/glob v0.2.3 // indirect
178-
github.com/goccy/go-json v0.10.2 // indirect
178+
github.com/goccy/go-json v0.10.3 // indirect
179179
github.com/godbus/dbus/v5 v5.0.6 // indirect
180180
github.com/gogo/protobuf v1.3.2 // indirect
181181
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect

exporter/datadogexporter/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporter/datadogexporter/integrationtest/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ require (
126126
github.com/go-openapi/swag v0.22.9 // indirect
127127
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
128128
github.com/gobwas/glob v0.2.3 // indirect
129-
github.com/goccy/go-json v0.10.2 // indirect
129+
github.com/goccy/go-json v0.10.3 // indirect
130130
github.com/godbus/dbus/v5 v5.0.6 // indirect
131131
github.com/gogo/protobuf v1.3.2 // indirect
132132
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect

0 commit comments

Comments
 (0)