From: Julian Zhu Date: Wed, 18 Jun 2025 09:26:26 +0000 (+0800) Subject: runtime: add benchmark for small-size memmory operation X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e84ed3864191fad224ad377054199661c34dd665;p=gostls13.git runtime: add benchmark for small-size memmory operation On RISC-V and MIPS andarchitectures, misaligned load/store is not mandatory for implementations. Therefore, it's important to handle memory operations involving small sizes or data with a remainder when divided by 8 or 4. This CL add some benchmark for small-size memmory operation, to ensure that SSA rules do not generate unaligned access traps on such architectures. Change-Id: I6fcdfdb76e9552d5b10df140fa92568ac9468386 Reviewed-on: https://go-review.googlesource.com/c/go/+/682575 Reviewed-by: Keith Randall Reviewed-by: Michael Knyszek Auto-Submit: Keith Randall Auto-Submit: Michael Knyszek LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- diff --git a/src/runtime/memmove_test.go b/src/runtime/memmove_test.go index 5649a20c5f..22905504d4 100644 --- a/src/runtime/memmove_test.go +++ b/src/runtime/memmove_test.go @@ -520,6 +520,42 @@ func BenchmarkMemclrRange(b *testing.B) { } } +func BenchmarkClearFat3(b *testing.B) { + p := new([3]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [3]byte{} + } +} + +func BenchmarkClearFat4(b *testing.B) { + p := new([4 / 4]uint32) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [4 / 4]uint32{} + } +} + +func BenchmarkClearFat5(b *testing.B) { + p := new([5]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [5]byte{} + } +} + +func BenchmarkClearFat6(b *testing.B) { + p := new([6]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [6]byte{} + } +} + func BenchmarkClearFat7(b *testing.B) { p := new([7]byte) Escape(p) @@ -538,6 +574,24 @@ func BenchmarkClearFat8(b *testing.B) { } } +func BenchmarkClearFat9(b *testing.B) { + p := new([9]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [9]byte{} + } +} + +func BenchmarkClearFat10(b *testing.B) { + p := new([10]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [10]byte{} + } +} + func BenchmarkClearFat11(b *testing.B) { p := new([11]byte) Escape(p) @@ -592,6 +646,24 @@ func BenchmarkClearFat16(b *testing.B) { } } +func BenchmarkClearFat18(b *testing.B) { + p := new([18]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [18]byte{} + } +} + +func BenchmarkClearFat20(b *testing.B) { + p := new([20 / 4]uint32) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = [20 / 4]uint32{} + } +} + func BenchmarkClearFat24(b *testing.B) { p := new([24 / 4]uint32) Escape(p) @@ -709,6 +781,46 @@ func BenchmarkClearFat1040(b *testing.B) { } } +func BenchmarkCopyFat3(b *testing.B) { + var x [3]byte + p := new([3]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + +func BenchmarkCopyFat4(b *testing.B) { + var x [4 / 4]uint32 + p := new([4 / 4]uint32) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + +func BenchmarkCopyFat5(b *testing.B) { + var x [5]byte + p := new([5]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + +func BenchmarkCopyFat6(b *testing.B) { + var x [6]byte + p := new([6]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + func BenchmarkCopyFat7(b *testing.B) { var x [7]byte p := new([7]byte) @@ -729,6 +841,26 @@ func BenchmarkCopyFat8(b *testing.B) { } } +func BenchmarkCopyFat9(b *testing.B) { + var x [9]byte + p := new([9]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + +func BenchmarkCopyFat10(b *testing.B) { + var x [10]byte + p := new([10]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + func BenchmarkCopyFat11(b *testing.B) { var x [11]byte p := new([11]byte) @@ -789,6 +921,26 @@ func BenchmarkCopyFat16(b *testing.B) { } } +func BenchmarkCopyFat18(b *testing.B) { + var x [18]byte + p := new([18]byte) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + +func BenchmarkCopyFat20(b *testing.B) { + var x [20 / 4]uint32 + p := new([20 / 4]uint32) + Escape(p) + b.ResetTimer() + for i := 0; i < b.N; i++ { + *p = x + } +} + func BenchmarkCopyFat24(b *testing.B) { var x [24 / 4]uint32 p := new([24 / 4]uint32)