zeroshade commented on code in PR #1391:
URL: https://github.com/apache/arrow-go/pull/1391#discussion_r4328419999
##########
arrow/compute/internal/kernels/vector_sort.go:
##########
@@ -454,6 +454,11 @@ func SortIndices(ctx *exec.KernelCtx, columns
[]*arrow.Chunked, keys []SortKey)
} else {
k0 := keys[0]
c0 := comparators[0]
+ if nRows >= radixSortMinRows &&
!c0.columnHasValidityNulls() &&
Review Comment:
Row count alone routes already-sorted and all-equal input here too, where
the existing sort is much faster. For 2,048 ascending Int64 values I measured
23.1–23.6 µs before versus 63.1–67.8 µs here (4 → 6 allocations), and at 65,536
rows 0.75–1.16 ms versus 2.8–3.3 ms. Could you benchmark sorted, all-equal and
random inputs around the threshold, and avoid the radix path (or otherwise the
regression) when the input is already in order?
##########
arrow/compute/internal/kernels/vector_sort_radix_test.go:
##########
@@ -0,0 +1,146 @@
+// 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.
+
+//go:build go1.22
+
+package kernels
+
+import (
+ "cmp"
+ "context"
+ "fmt"
+ "slices"
+ "testing"
+
+ "github.com/apache/arrow-go/v18/arrow"
+ "github.com/apache/arrow-go/v18/arrow/array"
+ "github.com/apache/arrow-go/v18/arrow/compute/exec"
+ "github.com/apache/arrow-go/v18/arrow/memory"
+)
+
+func checkRadixIntegerType[T radixInteger](t *testing.T, numBytes int, signBit
uint64) {
+ t.Helper()
+ ctx := &exec.KernelCtx{Ctx: exec.WithAllocator(context.Background(),
memory.NewGoAllocator())}
Review Comment:
Please use `memory.NewCheckedAllocator(memory.NewGoAllocator())` with a
final `AssertSize(t, 0)` here and in the sliced-array test. Removing `defer
scratchBuf.Release()` leaves both new tests passing; a checked allocator
catches the leaked scratch buffers.
--
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]