- Notifications
You must be signed in to change notification settings - Fork329
use simd masking for amd64&arm64#326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
26 commits Select commitHold shift + click to select a range
5df0303
mask.go: Use SIMD masking for amd64 and arm64
wdvxdr1123cda2170
Refactor and compile masking code again
nhooyrf5397ae
mask_asm.go: Disable AVX2
nhooyr14172e5
Benchmark pure go masking algorithm separately from assembly
nhooyr685a56e
Update README.md to indicate assembly websocket masking
nhooyrcb7509a
mask_amd64.s: Remove AVX2 fully
nhooyr3f8c9e0
mask_amd64.s: Minor improvements
nhooyr367743d
mask_amd64.sh: Cleanup
nhooyr27f80cb
mask.go: Cleanup assembly and add nbio benchmark
nhooyr369d641
mask_arm64.s: Cleanup
nhooyrfb13df2
ci/bench.sh: Benchmark masking on arm64 with QEMU
nhooyrecf7dec
ci/bench.sh: Install QEMU on CI
nhooyrd34e5d4
wsjson: Add json.Encoder vs json.Marshal benchmark
nhooyre25d968
ci/bench.sh: Don't profile by default
nhooyr640e3c2
ci/bench.sh: Try function instead of alias
nhooyr0596e7a
wsjson: Extend benchmark with multiple sizes
nhooyr30447a3
ci/bench.sh: Just symlink the expected qemu-aarch64 binary name
nhooyrf4e61e5
ci/fmt.sh: Error if changes on CI
nhooyrf533f43
mask.go: Reorganize
nhooyra1bb441
ci: Fix dev coverage output
nhooyrfee3739
mask_asm: Note implementation may not be perfect
nhooyr68fc887
mask.go: Revert my changes
nhooyrf62cef3
test.sh: Test assembly masking on arm64
nhooyr92acb74
internal/xcpu: Vendor golang.org/x/sys/cpu
nhooyr17e1b86
mask_asm: Disable AVX2
nhooyr2cd18b3
README.md: Link to assembly benchmark results
nhooyrFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
internal/xcpu: Vendor golang.org/x/sys/cpu
Standard library does this too. Unfortunate wish they just exposed it in thestandard library. Perhaps we can isolate the specific code we need later.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit92acb74883ce505cd4eefd32841ef807de3e78f8
There are no files selected for viewing
2 changes: 0 additions & 2 deletionsgo.mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
module nhooyr.io/websocket | ||
go 1.19 | ||
2 changes: 0 additions & 2 deletionsgo.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
2 changes: 0 additions & 2 deletionsinternal/examples/go.mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,5 +8,3 @@ require ( | ||
golang.org/x/time v0.3.0 | ||
nhooyr.io/websocket v0.0.0-00010101000000-000000000000 | ||
) | ||
2 changes: 0 additions & 2 deletionsinternal/examples/go.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= | ||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
10 changes: 10 additions & 0 deletionsinternal/xcpu/.gitattributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Treat all files in this repo as binary, with no git magic updating | ||
# line endings. Windows users contributing to Go will need to use a | ||
# modern version of git and editors capable of LF line endings. | ||
# | ||
# We'll prevent accidental CRLF line endings from entering the repo | ||
# via the git-review gofmt checks. | ||
# | ||
# See golang.org/issue/9281 | ||
* -text |
2 changes: 2 additions & 0 deletionsinternal/xcpu/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Add no patterns to .gitignore except for files generated by the build. | ||
last-change |
3 changes: 3 additions & 0 deletionsinternal/xcpu/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# cpu | ||
Vendored from https://github.com/golang/sys |
17 changes: 17 additions & 0 deletionsinternal/xcpu/asm_aix_ppc64.s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
//go:build gc | ||
#include "textflag.h" | ||
// | ||
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go | ||
// | ||
TEXT ·syscall6(SB),NOSPLIT,$0-88 | ||
JMPsyscall·syscall6(SB) | ||
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 | ||
JMPsyscall·rawSyscall6(SB) |
66 changes: 66 additions & 0 deletionsinternal/xcpu/byteorder.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
package xcpu | ||
import ( | ||
"runtime" | ||
) | ||
// byteOrder is a subset of encoding/binary.ByteOrder. | ||
type byteOrder interface { | ||
Uint32([]byte) uint32 | ||
Uint64([]byte) uint64 | ||
} | ||
type littleEndian struct{} | ||
type bigEndian struct{} | ||
func (littleEndian) Uint32(b []byte) uint32 { | ||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 | ||
} | ||
func (littleEndian) Uint64(b []byte) uint64 { | ||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | | ||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 | ||
} | ||
func (bigEndian) Uint32(b []byte) uint32 { | ||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 | ||
} | ||
func (bigEndian) Uint64(b []byte) uint64 { | ||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 | ||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | | ||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 | ||
} | ||
// hostByteOrder returns littleEndian on little-endian machines and | ||
// bigEndian on big-endian machines. | ||
func hostByteOrder() byteOrder { | ||
switch runtime.GOARCH { | ||
case "386", "amd64", "amd64p32", | ||
"alpha", | ||
"arm", "arm64", | ||
"loong64", | ||
"mipsle", "mips64le", "mips64p32le", | ||
"nios2", | ||
"ppc64le", | ||
"riscv", "riscv64", | ||
"sh": | ||
return littleEndian{} | ||
case "armbe", "arm64be", | ||
"m68k", | ||
"mips", "mips64", "mips64p32", | ||
"ppc", "ppc64", | ||
"s390", "s390x", | ||
"shbe", | ||
"sparc", "sparc64": | ||
return bigEndian{} | ||
} | ||
panic("unknown architecture") | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.