Skip to content

Commit e84ed38

Browse files
HeliC829gopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Keith Randall <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 18dbe5b commit e84ed38

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

src/runtime/memmove_test.go

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,42 @@ func BenchmarkMemclrRange(b *testing.B) {
520520
}
521521
}
522522

523+
func BenchmarkClearFat3(b *testing.B) {
524+
p := new([3]byte)
525+
Escape(p)
526+
b.ResetTimer()
527+
for i := 0; i < b.N; i++ {
528+
*p = [3]byte{}
529+
}
530+
}
531+
532+
func BenchmarkClearFat4(b *testing.B) {
533+
p := new([4 / 4]uint32)
534+
Escape(p)
535+
b.ResetTimer()
536+
for i := 0; i < b.N; i++ {
537+
*p = [4 / 4]uint32{}
538+
}
539+
}
540+
541+
func BenchmarkClearFat5(b *testing.B) {
542+
p := new([5]byte)
543+
Escape(p)
544+
b.ResetTimer()
545+
for i := 0; i < b.N; i++ {
546+
*p = [5]byte{}
547+
}
548+
}
549+
550+
func BenchmarkClearFat6(b *testing.B) {
551+
p := new([6]byte)
552+
Escape(p)
553+
b.ResetTimer()
554+
for i := 0; i < b.N; i++ {
555+
*p = [6]byte{}
556+
}
557+
}
558+
523559
func BenchmarkClearFat7(b *testing.B) {
524560
p := new([7]byte)
525561
Escape(p)
@@ -538,6 +574,24 @@ func BenchmarkClearFat8(b *testing.B) {
538574
}
539575
}
540576

577+
func BenchmarkClearFat9(b *testing.B) {
578+
p := new([9]byte)
579+
Escape(p)
580+
b.ResetTimer()
581+
for i := 0; i < b.N; i++ {
582+
*p = [9]byte{}
583+
}
584+
}
585+
586+
func BenchmarkClearFat10(b *testing.B) {
587+
p := new([10]byte)
588+
Escape(p)
589+
b.ResetTimer()
590+
for i := 0; i < b.N; i++ {
591+
*p = [10]byte{}
592+
}
593+
}
594+
541595
func BenchmarkClearFat11(b *testing.B) {
542596
p := new([11]byte)
543597
Escape(p)
@@ -592,6 +646,24 @@ func BenchmarkClearFat16(b *testing.B) {
592646
}
593647
}
594648

649+
func BenchmarkClearFat18(b *testing.B) {
650+
p := new([18]byte)
651+
Escape(p)
652+
b.ResetTimer()
653+
for i := 0; i < b.N; i++ {
654+
*p = [18]byte{}
655+
}
656+
}
657+
658+
func BenchmarkClearFat20(b *testing.B) {
659+
p := new([20 / 4]uint32)
660+
Escape(p)
661+
b.ResetTimer()
662+
for i := 0; i < b.N; i++ {
663+
*p = [20 / 4]uint32{}
664+
}
665+
}
666+
595667
func BenchmarkClearFat24(b *testing.B) {
596668
p := new([24 / 4]uint32)
597669
Escape(p)
@@ -709,6 +781,46 @@ func BenchmarkClearFat1040(b *testing.B) {
709781
}
710782
}
711783

784+
func BenchmarkCopyFat3(b *testing.B) {
785+
var x [3]byte
786+
p := new([3]byte)
787+
Escape(p)
788+
b.ResetTimer()
789+
for i := 0; i < b.N; i++ {
790+
*p = x
791+
}
792+
}
793+
794+
func BenchmarkCopyFat4(b *testing.B) {
795+
var x [4 / 4]uint32
796+
p := new([4 / 4]uint32)
797+
Escape(p)
798+
b.ResetTimer()
799+
for i := 0; i < b.N; i++ {
800+
*p = x
801+
}
802+
}
803+
804+
func BenchmarkCopyFat5(b *testing.B) {
805+
var x [5]byte
806+
p := new([5]byte)
807+
Escape(p)
808+
b.ResetTimer()
809+
for i := 0; i < b.N; i++ {
810+
*p = x
811+
}
812+
}
813+
814+
func BenchmarkCopyFat6(b *testing.B) {
815+
var x [6]byte
816+
p := new([6]byte)
817+
Escape(p)
818+
b.ResetTimer()
819+
for i := 0; i < b.N; i++ {
820+
*p = x
821+
}
822+
}
823+
712824
func BenchmarkCopyFat7(b *testing.B) {
713825
var x [7]byte
714826
p := new([7]byte)
@@ -729,6 +841,26 @@ func BenchmarkCopyFat8(b *testing.B) {
729841
}
730842
}
731843

844+
func BenchmarkCopyFat9(b *testing.B) {
845+
var x [9]byte
846+
p := new([9]byte)
847+
Escape(p)
848+
b.ResetTimer()
849+
for i := 0; i < b.N; i++ {
850+
*p = x
851+
}
852+
}
853+
854+
func BenchmarkCopyFat10(b *testing.B) {
855+
var x [10]byte
856+
p := new([10]byte)
857+
Escape(p)
858+
b.ResetTimer()
859+
for i := 0; i < b.N; i++ {
860+
*p = x
861+
}
862+
}
863+
732864
func BenchmarkCopyFat11(b *testing.B) {
733865
var x [11]byte
734866
p := new([11]byte)
@@ -789,6 +921,26 @@ func BenchmarkCopyFat16(b *testing.B) {
789921
}
790922
}
791923

924+
func BenchmarkCopyFat18(b *testing.B) {
925+
var x [18]byte
926+
p := new([18]byte)
927+
Escape(p)
928+
b.ResetTimer()
929+
for i := 0; i < b.N; i++ {
930+
*p = x
931+
}
932+
}
933+
934+
func BenchmarkCopyFat20(b *testing.B) {
935+
var x [20 / 4]uint32
936+
p := new([20 / 4]uint32)
937+
Escape(p)
938+
b.ResetTimer()
939+
for i := 0; i < b.N; i++ {
940+
*p = x
941+
}
942+
}
943+
792944
func BenchmarkCopyFat24(b *testing.B) {
793945
var x [24 / 4]uint32
794946
p := new([24 / 4]uint32)

0 commit comments

Comments
 (0)