This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new 74ebd3a fix(internal/json): add arrow_json_stdlib build tag (#199)
74ebd3a is described below
commit 74ebd3a280f95806647a2b3d87fa4e94a4cc2b5e
Author: Todd Treece <[email protected]>
AuthorDate: Wed Dec 4 12:43:26 2024 -0500
fix(internal/json): add arrow_json_stdlib build tag (#199)
### Rationale for this change
Grafana and Grafana plugins both use arrow-go, but do not use arrow's
`internal/json`. A decent amount of used heap is initialized by
https://github.com/goccy/go-json, so it would be useful to be able to
prevent the initialization.
The example below shows that 60% of this heap profile in a Grafana
plugin is used by `go-json`'s encoder & decoder packages.

I have submitted a [PR to
go-json](https://github.com/goccy/go-json/pull/490) to switch to lazy
initialization (additional details in the PR), but I am having a hard
time getting a response from the maintainer, so am attempting a
different approach to the problem with this PR.
### What changes are included in this PR?
Adds `arrow_json_stdlib` build tag so that it's possible to switch to
`encoding/json` and avoid the overhead of
https://github.com/goccy/go-json.
### Are these changes tested?
I tested this locally, but I can add coverage if this seems like an
acceptable approach.
### Are there any user-facing changes?
---
internal/json/json.go | 4 ++--
internal/json/{json_tinygo.go => json_stdlib.go} | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/internal/json/json.go b/internal/json/json.go
index 319b12c..b4c4c9f 100644
--- a/internal/json/json.go
+++ b/internal/json/json.go
@@ -14,8 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-//go:build !tinygo
-// +build !tinygo
+//go:build !tinygo && !arrow_json_stdlib
+// +build !tinygo,!arrow_json_stdlib
package json
diff --git a/internal/json/json_tinygo.go b/internal/json/json_stdlib.go
similarity index 94%
rename from internal/json/json_tinygo.go
rename to internal/json/json_stdlib.go
index 8e4f447..3031029 100644
--- a/internal/json/json_tinygo.go
+++ b/internal/json/json_stdlib.go
@@ -14,8 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-//go:build tinygo
-// +build tinygo
+//go:build tinygo || arrow_json_stdlib
+// +build tinygo arrow_json_stdlib
package json