From 9e499ea6898d3810e9ae9b463dad781ce0deff93 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 21 Apr 2022 17:20:35 -0700 Subject: [PATCH 1/2] .github: update to Go 1.18.1 Also regenerate all of the stubs, we don't need "+build" anymore because both Go 1.17 and 1.18 use "go:build" for build tags. --- .github/workflows/go.yml | 15 ++++++--------- ascii/equal_fold_amd64.go | 1 - ascii/equal_fold_amd64.s | 1 - ascii/valid_amd64.go | 1 - ascii/valid_amd64.s | 1 - ascii/valid_print_amd64.go | 1 - ascii/valid_print_amd64.s | 1 - base64/decode_amd64.go | 1 - base64/decode_amd64.s | 1 - base64/encode_amd64.go | 1 - base64/encode_amd64.s | 1 - bswap/swap64_amd64.go | 1 - bswap/swap64_amd64.s | 1 - keyset/keyset_amd64.go | 1 - keyset/keyset_amd64.s | 1 - mem/blend_amd64.go | 1 - mem/blend_amd64.s | 1 - mem/contains_amd64.go | 1 - mem/contains_amd64.s | 1 - mem/copy_amd64.go | 1 - mem/copy_amd64.s | 1 - mem/count_pair_amd64.go | 1 - mem/count_pair_amd64.s | 1 - mem/index_pair_amd64.go | 1 - mem/index_pair_amd64.s | 1 - mem/mask_amd64.go | 1 - mem/mask_amd64.s | 1 - qsort/sort_amd64.go | 1 - qsort/sort_amd64.s | 1 - slices/sums_amd64.go | 1 - slices/sums_amd64.s | 1 - sortedset/dedupe_amd64.go | 1 - sortedset/dedupe_amd64.s | 1 - sortedset/intersect16_amd64.go | 1 - sortedset/intersect16_amd64.s | 1 - sortedset/union16_amd64.go | 1 - sortedset/union16_amd64.s | 1 - utf8/valid_amd64.go | 1 - utf8/valid_amd64.s | 1 - 39 files changed, 6 insertions(+), 47 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 52246f46..c5b2bc61 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -7,8 +7,8 @@ jobs: strategy: matrix: go: - - 1.16 - - 1.17 + - 1.17.x + - 1.18.x os: - ubuntu-latest @@ -43,12 +43,9 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: 1.17.x + go-version: 1.18.x - - name: Generate - run: make --always-make build - - - name: Git Status + - name: Ensure generated assembler code is up to date run: | - git diff - test -z "$(git status --porcelain)" + go install github.com/kevinburke/differ@1.2 + differ make --always-make build diff --git a/ascii/equal_fold_amd64.go b/ascii/equal_fold_amd64.go index 07cf6cdb..117b2297 100644 --- a/ascii/equal_fold_amd64.go +++ b/ascii/equal_fold_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run equal_fold_asm.go -pkg ascii -out ../ascii/equal_fold_amd64.s -stubs ../ascii/equal_fold_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package ascii diff --git a/ascii/equal_fold_amd64.s b/ascii/equal_fold_amd64.s index 34495a62..36fc9930 100644 --- a/ascii/equal_fold_amd64.s +++ b/ascii/equal_fold_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run equal_fold_asm.go -pkg ascii -out ../ascii/equal_fold_amd64.s -stubs ../ascii/equal_fold_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/ascii/valid_amd64.go b/ascii/valid_amd64.go index 72dc7b43..14d3f64e 100644 --- a/ascii/valid_amd64.go +++ b/ascii/valid_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run valid_asm.go -pkg ascii -out ../ascii/valid_amd64.s -stubs ../ascii/valid_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package ascii diff --git a/ascii/valid_amd64.s b/ascii/valid_amd64.s index 0214b0ce..d0dc2355 100644 --- a/ascii/valid_amd64.s +++ b/ascii/valid_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run valid_asm.go -pkg ascii -out ../ascii/valid_amd64.s -stubs ../ascii/valid_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/ascii/valid_print_amd64.go b/ascii/valid_print_amd64.go index b1462666..3eef8c5b 100644 --- a/ascii/valid_print_amd64.go +++ b/ascii/valid_print_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run valid_print_asm.go -pkg ascii -out ../ascii/valid_print_amd64.s -stubs ../ascii/valid_print_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package ascii diff --git a/ascii/valid_print_amd64.s b/ascii/valid_print_amd64.s index bc2e20a2..8b957294 100644 --- a/ascii/valid_print_amd64.s +++ b/ascii/valid_print_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run valid_print_asm.go -pkg ascii -out ../ascii/valid_print_amd64.s -stubs ../ascii/valid_print_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/base64/decode_amd64.go b/base64/decode_amd64.go index 1dae5b43..e85bf6a9 100644 --- a/base64/decode_amd64.go +++ b/base64/decode_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run decode_asm.go -pkg base64 -out ../base64/decode_amd64.s -stubs ../base64/decode_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package base64 diff --git a/base64/decode_amd64.s b/base64/decode_amd64.s index cc6c779d..ade5442c 100644 --- a/base64/decode_amd64.s +++ b/base64/decode_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run decode_asm.go -pkg base64 -out ../base64/decode_amd64.s -stubs ../base64/decode_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/base64/encode_amd64.go b/base64/encode_amd64.go index c38060f7..a83c81f1 100644 --- a/base64/encode_amd64.go +++ b/base64/encode_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run encode_asm.go -pkg base64 -out ../base64/encode_amd64.s -stubs ../base64/encode_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package base64 diff --git a/base64/encode_amd64.s b/base64/encode_amd64.s index 2edd27aa..6797c977 100644 --- a/base64/encode_amd64.s +++ b/base64/encode_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run encode_asm.go -pkg base64 -out ../base64/encode_amd64.s -stubs ../base64/encode_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/bswap/swap64_amd64.go b/bswap/swap64_amd64.go index 04bbb58d..ebbe64ef 100644 --- a/bswap/swap64_amd64.go +++ b/bswap/swap64_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run swap64_asm.go -pkg bswap -out ../bswap/swap64_amd64.s -stubs ../bswap/swap64_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package bswap diff --git a/bswap/swap64_amd64.s b/bswap/swap64_amd64.s index 9d6fb5bb..887f5b4a 100644 --- a/bswap/swap64_amd64.s +++ b/bswap/swap64_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run swap64_asm.go -pkg bswap -out ../bswap/swap64_amd64.s -stubs ../bswap/swap64_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/keyset/keyset_amd64.go b/keyset/keyset_amd64.go index 9554ee67..0390db71 100644 --- a/keyset/keyset_amd64.go +++ b/keyset/keyset_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run keyset_asm.go -pkg keyset -out ../keyset/keyset_amd64.s -stubs ../keyset/keyset_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package keyset diff --git a/keyset/keyset_amd64.s b/keyset/keyset_amd64.s index e27d2c45..cdfbd7f4 100644 --- a/keyset/keyset_amd64.s +++ b/keyset/keyset_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run keyset_asm.go -pkg keyset -out ../keyset/keyset_amd64.s -stubs ../keyset/keyset_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/blend_amd64.go b/mem/blend_amd64.go index 0607eadc..845bfb59 100644 --- a/mem/blend_amd64.go +++ b/mem/blend_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run blend_asm.go -pkg mem -out ../mem/blend_amd64.s -stubs ../mem/blend_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/blend_amd64.s b/mem/blend_amd64.s index 7aa77640..8dfa5620 100644 --- a/mem/blend_amd64.s +++ b/mem/blend_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run blend_asm.go -pkg mem -out ../mem/blend_amd64.s -stubs ../mem/blend_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/contains_amd64.go b/mem/contains_amd64.go index ab2d9280..4246db32 100644 --- a/mem/contains_amd64.go +++ b/mem/contains_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run contains_asm.go -pkg mem -out ../mem/contains_amd64.s -stubs ../mem/contains_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/contains_amd64.s b/mem/contains_amd64.s index 5396a41f..483617b8 100644 --- a/mem/contains_amd64.s +++ b/mem/contains_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run contains_asm.go -pkg mem -out ../mem/contains_amd64.s -stubs ../mem/contains_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/copy_amd64.go b/mem/copy_amd64.go index f8393139..856ba92e 100644 --- a/mem/copy_amd64.go +++ b/mem/copy_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run copy_asm.go -pkg mem -out ../mem/copy_amd64.s -stubs ../mem/copy_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/copy_amd64.s b/mem/copy_amd64.s index e506c5f2..cb5578d5 100644 --- a/mem/copy_amd64.s +++ b/mem/copy_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run copy_asm.go -pkg mem -out ../mem/copy_amd64.s -stubs ../mem/copy_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/count_pair_amd64.go b/mem/count_pair_amd64.go index 17f078f7..68af1fe8 100644 --- a/mem/count_pair_amd64.go +++ b/mem/count_pair_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run count_pair_asm.go -pkg mem -out ../mem/count_pair_amd64.s -stubs ../mem/count_pair_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/count_pair_amd64.s b/mem/count_pair_amd64.s index 924b0263..ab3fd228 100644 --- a/mem/count_pair_amd64.s +++ b/mem/count_pair_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run count_pair_asm.go -pkg mem -out ../mem/count_pair_amd64.s -stubs ../mem/count_pair_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/index_pair_amd64.go b/mem/index_pair_amd64.go index 49aa11fd..9807c9db 100644 --- a/mem/index_pair_amd64.go +++ b/mem/index_pair_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run index_pair_asm.go -pkg mem -out ../mem/index_pair_amd64.s -stubs ../mem/index_pair_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/index_pair_amd64.s b/mem/index_pair_amd64.s index df1b06cd..23c92320 100644 --- a/mem/index_pair_amd64.s +++ b/mem/index_pair_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run index_pair_asm.go -pkg mem -out ../mem/index_pair_amd64.s -stubs ../mem/index_pair_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/mem/mask_amd64.go b/mem/mask_amd64.go index 7724eb6c..6a42f917 100644 --- a/mem/mask_amd64.go +++ b/mem/mask_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run mask_asm.go -pkg mem -out ../mem/mask_amd64.s -stubs ../mem/mask_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package mem diff --git a/mem/mask_amd64.s b/mem/mask_amd64.s index 3fd32227..438be4bb 100644 --- a/mem/mask_amd64.s +++ b/mem/mask_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run mask_asm.go -pkg mem -out ../mem/mask_amd64.s -stubs ../mem/mask_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/qsort/sort_amd64.go b/qsort/sort_amd64.go index bc9bdd60..214d4dde 100644 --- a/qsort/sort_amd64.go +++ b/qsort/sort_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run sort_asm.go -pkg qsort -out ../qsort/sort_amd64.s -stubs ../qsort/sort_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package qsort diff --git a/qsort/sort_amd64.s b/qsort/sort_amd64.s index bf67efa8..e745b246 100644 --- a/qsort/sort_amd64.s +++ b/qsort/sort_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run sort_asm.go -pkg qsort -out ../qsort/sort_amd64.s -stubs ../qsort/sort_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/slices/sums_amd64.go b/slices/sums_amd64.go index 426df8e9..eabb99de 100644 --- a/slices/sums_amd64.go +++ b/slices/sums_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run sums_asm.go -pkg slices -out ../slices/sums_amd64.s -stubs ../slices/sums_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package slices diff --git a/slices/sums_amd64.s b/slices/sums_amd64.s index 8ae09afd..c6e818f0 100644 --- a/slices/sums_amd64.s +++ b/slices/sums_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run sums_asm.go -pkg slices -out ../slices/sums_amd64.s -stubs ../slices/sums_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/sortedset/dedupe_amd64.go b/sortedset/dedupe_amd64.go index ab4c7a3b..a9f745e5 100644 --- a/sortedset/dedupe_amd64.go +++ b/sortedset/dedupe_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run dedupe_asm.go -pkg sortedset -out ../sortedset/dedupe_amd64.s -stubs ../sortedset/dedupe_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package sortedset diff --git a/sortedset/dedupe_amd64.s b/sortedset/dedupe_amd64.s index 3436013b..2f60fd97 100644 --- a/sortedset/dedupe_amd64.s +++ b/sortedset/dedupe_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run dedupe_asm.go -pkg sortedset -out ../sortedset/dedupe_amd64.s -stubs ../sortedset/dedupe_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/sortedset/intersect16_amd64.go b/sortedset/intersect16_amd64.go index cc1a9536..50566de0 100644 --- a/sortedset/intersect16_amd64.go +++ b/sortedset/intersect16_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run intersect16_asm.go -pkg sortedset -out ../sortedset/intersect16_amd64.s -stubs ../sortedset/intersect16_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package sortedset diff --git a/sortedset/intersect16_amd64.s b/sortedset/intersect16_amd64.s index 4d05ac0d..80ef026c 100644 --- a/sortedset/intersect16_amd64.s +++ b/sortedset/intersect16_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run intersect16_asm.go -pkg sortedset -out ../sortedset/intersect16_amd64.s -stubs ../sortedset/intersect16_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/sortedset/union16_amd64.go b/sortedset/union16_amd64.go index 786b1267..500dad9d 100644 --- a/sortedset/union16_amd64.go +++ b/sortedset/union16_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run union16_asm.go -pkg sortedset -out ../sortedset/union16_amd64.s -stubs ../sortedset/union16_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package sortedset diff --git a/sortedset/union16_amd64.s b/sortedset/union16_amd64.s index a5fe041a..71a4152a 100644 --- a/sortedset/union16_amd64.s +++ b/sortedset/union16_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run union16_asm.go -pkg sortedset -out ../sortedset/union16_amd64.s -stubs ../sortedset/union16_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" diff --git a/utf8/valid_amd64.go b/utf8/valid_amd64.go index d9e9612d..c18cff67 100644 --- a/utf8/valid_amd64.go +++ b/utf8/valid_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run valid_asm.go -pkg utf8 -out ../utf8/valid_amd64.s -stubs ../utf8/valid_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego package utf8 diff --git a/utf8/valid_amd64.s b/utf8/valid_amd64.s index 501dfc62..cf7a3916 100644 --- a/utf8/valid_amd64.s +++ b/utf8/valid_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run valid_asm.go -pkg utf8 -out ../utf8/valid_amd64.s -stubs ../utf8/valid_amd64.go. DO NOT EDIT. //go:build !purego -// +build !purego #include "textflag.h" From 52fc5735a2101856fcdbc45c901ce51562127c99 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 27 Apr 2022 13:25:58 -0700 Subject: [PATCH 2/2] README.md: mention minimum Go version --- README.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 83cd608a..db7b1673 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,16 @@ # asm ![build status](https://github.com/segmentio/asm/actions/workflows/go.yml/badge.svg) [![GoDoc](https://godoc.org/github.com/segmentio/asm?status.svg)](https://godoc.org/github.com/segmentio/asm) -Go library providing algorithms optimized to leverage the characteristics of -modern CPUs. +Go library providing algorithms that use the full power of modern CPUs to get +the best performance. ## Motivation -With the development of Cloud technologies, access to large scale compute -capacity has never been easier, and running distributed systems deployed across -dozens or sometimes hundreds of CPUs has become common practice. As a side -effect of being provided seemingly unlimited (but somewhat expensive) compute -capacity, software engineers are now in direct connections with the economical -and environmental impact of running the software they develop in production; -performance and efficiency of our programs matters today more than it has ever -before. +The cloud makes it easier than ever to access large scale compute capacity, +and it's become common to run distributed systems deployed across dozens or +sometimes hundreds of CPUs. Because projects run on so many cores now, program +performance and efficiency matters more today than it has ever before. -Modern CPUs are complex machines with performance characteristic that may +Modern CPUs are complex machines with performance characteristics that may vary by orders of magnitude depending on how they are used. Features like branch prediction, instruction reordering, pipelining, or caching are all input variables that determine the compute throughput that a CPU can achieve. @@ -102,7 +98,7 @@ Sort16/1000000 59.4MB/s ± 2% 351.2MB/s ± 3% +491.24% (p=0.008 n=5+5) ## Maintenance -Generation of the assembly code is managed with [AVO](https://github.com/mmcloughlin/avo), +The assembly code is generated with [AVO](https://github.com/mmcloughlin/avo), and orchestrated by a Makefile which helps maintainers rebuild the assembly source code when the AVO files are modified. @@ -121,6 +117,17 @@ stable APIs on the main package, breaking changes may be introduced on the `build` package more often, as it is intended to be ground for more experimental constructs in the project. +### Requirements + +Some libraries have custom purpose code for both amd64 and arm64. Others (qsort) +have only amd64. Search for a `.s` file matching your architecture to be sure +you are using the assembler optimized library instructions. + +The Go code requires Go 1.17 or above. These versions contain significant +performance improvements compared to previous Go versions. + +`asm` version v1.1.5 and earlier maintain compatibility with Go 1.16. + ### purego Programs in the `build` module should add the following declaration: @@ -132,7 +139,7 @@ func init() { ``` It instructs AVO to inject the `!purego` tag in the generated files, allowing -compilation of the libraries without any assembly optimizations with a build +the libraries to be compiled without any assembly optimizations with a build command such as: ``` @@ -141,4 +148,3 @@ go build -tags purego ... This is mainly useful to compare the impact of using the assembly optimized versions instead of the simpler Go-only implementations. -