Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
nhooyr merged 26 commits intocoder:devfromwdvxdr1123:patch-simd-mask
Feb 22, 2024
Merged
Show file tree
Hide file tree
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
wdvxdr1123Jan 24, 2022
cda2170
Refactor and compile masking code again
nhooyrOct 19, 2023
f5397ae
mask_asm.go: Disable AVX2
nhooyrOct 19, 2023
14172e5
Benchmark pure go masking algorithm separately from assembly
nhooyrOct 19, 2023
685a56e
Update README.md to indicate assembly websocket masking
nhooyrOct 19, 2023
cb7509a
mask_amd64.s: Remove AVX2 fully
nhooyrOct 19, 2023
3f8c9e0
mask_amd64.s: Minor improvements
nhooyrOct 19, 2023
367743d
mask_amd64.sh: Cleanup
nhooyrOct 19, 2023
27f80cb
mask.go: Cleanup assembly and add nbio benchmark
nhooyrOct 19, 2023
369d641
mask_arm64.s: Cleanup
nhooyrOct 20, 2023
fb13df2
ci/bench.sh: Benchmark masking on arm64 with QEMU
nhooyrOct 20, 2023
ecf7dec
ci/bench.sh: Install QEMU on CI
nhooyrOct 20, 2023
d34e5d4
wsjson: Add json.Encoder vs json.Marshal benchmark
nhooyrOct 20, 2023
e25d968
ci/bench.sh: Don't profile by default
nhooyrOct 20, 2023
640e3c2
ci/bench.sh: Try function instead of alias
nhooyrOct 20, 2023
0596e7a
wsjson: Extend benchmark with multiple sizes
nhooyrOct 20, 2023
30447a3
ci/bench.sh: Just symlink the expected qemu-aarch64 binary name
nhooyrOct 20, 2023
f4e61e5
ci/fmt.sh: Error if changes on CI
nhooyrOct 21, 2023
f533f43
mask.go: Reorganize
nhooyrOct 21, 2023
a1bb441
ci: Fix dev coverage output
nhooyrFeb 7, 2024
fee3739
mask_asm: Note implementation may not be perfect
nhooyrFeb 7, 2024
68fc887
mask.go: Revert my changes
nhooyrFeb 22, 2024
f62cef3
test.sh: Test assembly masking on arm64
nhooyrFeb 22, 2024
92acb74
internal/xcpu: Vendor golang.org/x/sys/cpu
nhooyrFeb 22, 2024
17e1b86
mask_asm: Disable AVX2
nhooyrFeb 22, 2024
2cd18b3
README.md: Link to assembly benchmark results
nhooyrFeb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
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
@nhooyr
nhooyr committedFeb 22, 2024
commit92acb74883ce505cd4eefd32841ef807de3e78f8
2 changes: 0 additions & 2 deletionsgo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
module nhooyr.io/websocket

go 1.19

require golang.org/x/sys v0.17.0
2 changes: 0 additions & 2 deletionsgo.sum
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 0 additions & 2 deletionsinternal/examples/go.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,5 +8,3 @@ require (
golang.org/x/time v0.3.0
nhooyr.io/websocket v0.0.0-00010101000000-000000000000
)

require golang.org/x/sys v0.17.0 // indirect
2 changes: 0 additions & 2 deletionsinternal/examples/go.sum
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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")
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp