This is an automated email from the ASF dual-hosted git repository.
laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new b2bce714f perf(table): avoid fmt in partition summaries (#2142)
b2bce714f is described below
commit b2bce714f67d3b086cfcc9f63c2a87b5f76f73a8
Author: Minh Vu <[email protected]>
AuthorDate: Fri Oct 9 18:20:26 2026 +0200
perf(table): avoid fmt in partition summaries (#2142)
* perf(table): avoid fmt in partition summaries
* test(table): benchmark partition summary generation
* perf(table): preallocate partition summary entries
Signed-off-by: Minh Vu <[email protected]>
---
table/snapshots.go | 13 +++++-----
table/snapshots_bench_test.go | 56 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 7 deletions(-)
diff --git a/table/snapshots.go b/table/snapshots.go
index 4d084332b..36b828574 100644
--- a/table/snapshots.go
+++ b/table/snapshots.go
@@ -637,14 +637,13 @@ func (s *SnapshotSummaryCollector) removeFile(df
iceberg.DataFile, sc *iceberg.S
func (s *SnapshotSummaryCollector) partitionSummary(metrics *updateMetrics)
string {
props := metrics.toProps()
+ parts := make([]string, 0, len(props))
+ for k, v := range props {
+ parts = append(parts, k+"="+v)
+ }
+ slices.Sort(parts)
- return strings.Join(slices.Sorted(func(yield func(s string) bool) {
- for k, v := range props {
- if !yield(fmt.Sprintf("%s=%s", k, v)) {
- return
- }
- }
- }), ",")
+ return strings.Join(parts, ",")
}
func (s *SnapshotSummaryCollector) build() iceberg.Properties {
diff --git a/table/snapshots_bench_test.go b/table/snapshots_bench_test.go
new file mode 100644
index 000000000..d8af4d272
--- /dev/null
+++ b/table/snapshots_bench_test.go
@@ -0,0 +1,56 @@
+// 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 table
+
+import "testing"
+
+var partitionSummaryBenchmarkResult string
+
+func BenchmarkPartitionSummary(b *testing.B) {
+ cases := []struct {
+ name string
+ metrics updateMetrics
+ }{
+ {"empty", updateMetrics{}},
+ {"append", updateMetrics{addedFileSize: 123456, addedDataFiles:
10, addedRecords: 1000}},
+ {"overwrite", updateMetrics{
+ addedFileSize: 123456, removedFileSize: 654321,
+ addedDataFiles: 10, removedDataFiles: 20,
+ addedRecords: 1000, deletedRecords: 2000,
+ }},
+ {"all", updateMetrics{
+ addedFileSize: 123456, removedFileSize: 654321,
+ addedDataFiles: 10, removedDataFiles: 20,
+ addedEqDeleteFiles: 3, removedEqDeleteFiles: 4,
+ addedPosDeleteFiles: 5, removedPosDeleteFiles: 6,
+ addedDeleteFiles: 8, removedDeleteFiles: 10,
+ addedRecords: 1000, deletedRecords: 2000,
+ addedPosDeletes: 300, removedPosDeletes: 400,
+ addedEqDeletes: 500, removedEqDeletes: 600,
+ }},
+ }
+ for _, tc := range cases {
+ b.Run(tc.name, func(b *testing.B) {
+ var collector SnapshotSummaryCollector
+ b.ReportAllocs()
+ for b.Loop() {
+ partitionSummaryBenchmarkResult =
collector.partitionSummary(&tc.metrics)
+ }
+ })
+ }
+}