laskoviymishka commented on code in PR #1654:
URL: https://github.com/apache/iceberg-go/pull/1654#discussion_r3779436063


##########
catalog/rest/load_table_bench_test.go:
##########
@@ -0,0 +1,201 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package rest
+
+import (
+       "encoding/json"
+       "fmt"
+       "testing"
+
+       "github.com/apache/iceberg-go/table"
+       "github.com/google/uuid"
+       "github.com/stretchr/testify/require"
+)
+
+// BenchmarkDecodeTableMetadata benchmarks the json decoding of LoadTable 
responses. Because responses can get big
+// with tables with a long snapshot history, the impact of the json decoding 
performance can be significant in
+// higher-throughput workloads. This benchmark can be extended to experiment 
with other json decoder for
+// performance comparisons.
+func BenchmarkDecodeTableMetadata(b *testing.B) {
+       snapshotCounts := []struct {
+               name          string
+               snapshotCount int64
+               decode        func(body []byte, v any) error
+       }{
+               {
+                       name:          "1 snapshot, encoding/json",
+                       snapshotCount: 1,
+                       decode: func(body []byte, v any) error {
+                               return json.Unmarshal(body, v)
+                       },
+               },
+               {
+                       name:          "10 snapshots, encoding/json",
+                       snapshotCount: 10,
+                       decode: func(body []byte, v any) error {
+                               return json.Unmarshal(body, v)
+                       },
+               },
+               {
+                       name:          "100 snapshots, encoding/json",
+                       snapshotCount: 100,
+                       decode: func(body []byte, v any) error {
+                               return json.Unmarshal(body, v)
+                       },
+               },
+               {
+                       name:          "1000 snapshots, encoding/json",
+                       snapshotCount: 1000,
+                       decode: func(body []byte, v any) error {
+                               return json.Unmarshal(body, v)
+                       },
+               },
+               {
+                       name:          "10000 snapshots, encoding/json",
+                       snapshotCount: 10000,
+                       decode: func(body []byte, v any) error {
+                               return json.Unmarshal(body, v)
+                       },
+               },
+               {
+                       name:          "10000 snapshots, goccy/go-json",

Review Comment:
   This row is labeled `goccy/go-json` but its decode closure calls 
`encoding/json`'s Unmarshal, identical to the `encoding/json` row above it, so 
the benchmark reports two 10000-snapshot numbers that are the same decoder 
under two names. The whole point of the harness is comparing decoders, so a 
mislabeled slot is worse than no slot: anyone reading the output concludes 
goccy is a wash, on fake data.
   
   I'd drop this entry until there's a real second decoder to put here. Matt's 
suggestion of `encoding/json/v2` on 1.26 is the natural thing to slot in: a 
real comparison and no third-party risk. wdyt?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to