diff --git a/.github/workflows/autobahn.yml b/.github/workflows/autobahn.yml deleted file mode 100644 index c404e0d..0000000 --- a/.github/workflows/autobahn.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Autobahn - -on: - push: - branches: - - master - - dev - pull_request: - branches: - - master - - dev - -jobs: - Autobahn: - strategy: - matrix: - os: [ ubuntu-latest ] - go: [ 1.18.x ] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go }} - - name: Autobahn Test - env: - CRYPTOGRAPHY_ALLOW_OPENSSL_102: yes - run: | - chmod +x ./autobahn/script/run.sh & ./autobahn/script/run.sh - - name: Autobahn Report Artifact - if: >- - startsWith(matrix.os, 'ubuntu') - uses: actions/upload-artifact@v2 - - with: - name: autobahn report ${{ matrix.go }} ${{ matrix.os }} - path: autobahn/report - retention-days: 7 diff --git a/README.md b/README.md index 0460f26..029537d 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,65 @@ func main() { } } ``` +## 100w websocket长链接测试 +### e5 洋垃圾机器 +* cpu=e5 2686(单路) +* memory=32GB +``` +BenchType : BenchEcho +Framework : greatws +TPS : 27954 +EER : 225.42 +Min : 35.05us +Avg : 1.79s +Max : 2.74s +TP50 : 1.88s +TP75 : 1.95s +TP90 : 1.99s +TP95 : 2.02s +TP99 : 2.09s +Used : 178.86s +Total : 5000000 +Success : 5000000 +Failed : 0 +Conns : 1000000 +Concurrency: 50000 +Payload : 1024 +CPU Min : 41.62% +CPU Avg : 124.01% +CPU Max : 262.72% +MEM Min : 555.25M +MEM Avg : 562.44M +MEM Max : 626.47M +``` + +### 5800h cpu +* cpu=5800h +* memory=64GB +``` +BenchType : BenchEcho +Framework : greatws +TPS : 82088 +EER : 447.72 +Min : -1ns +Avg : 605.25ms +Max : 1.68s +TP50 : 609.79ms +TP75 : 709.26ms +TP90 : 761.86ms +TP95 : 771.77ms +TP99 : 779.10ms +Used : 50.47s +Total : 5000000 +Success : 4142842 +Failed : 857158 +Conns : 1000000 +Concurrency: 50000 +Payload : 1024 +CPU Min : 114.33% +CPU Avg : 183.35% +CPU Max : 280.22% +MEM Min : 625.27M +MEM Avg : 632.89M +MEM Max : 666.96M +``` \ No newline at end of file diff --git a/conn_unix.go b/conn_unix.go index fc7828c..e760131 100644 --- a/conn_unix.go +++ b/conn_unix.go @@ -77,13 +77,13 @@ type Conn struct { wbuf *[]byte // 写缓冲区, 当直接Write失败时,会将数据写入缓冲区 mu sync.Mutex // 锁 - client bool // 客户端为true,服务端为false *Config // 配置 - closed int32 // 是否关闭 - closeOnce sync.Once // 关闭一次 parent *EventLoop // event loop currBindGo *businessGo // 绑定模式下,当前绑定的go程 - streamGo taskStream // stream模式下,当前绑定的go程 + streamGo *taskStream // stream模式下,当前绑定的go程 + closeOnce sync.Once // 关闭一次 + closed int32 // 是否关闭 + client bool // 客户端为true,服务端为false } func newConn(fd int64, client bool, conf *Config) *Conn { @@ -98,7 +98,7 @@ func newConn(fd int64, client bool, conf *Config) *Conn { } if conf.runInGoStrategy == taskStrategyStream { - c.streamGo.init() + c.streamGo = newTaskStream() } return c } diff --git a/go.mod b/go.mod index 4ca6e79..355178a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/antlabs/greatws go 1.21 require ( - github.com/antlabs/wsutil v0.1.6 + github.com/antlabs/wsutil v0.1.7 github.com/pawelgaczynski/giouring v0.0.0-20230826085535-69588b89acb9 golang.org/x/sys v0.12.0 ) diff --git a/go.sum b/go.sum index 6adce8c..a397664 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/antlabs/wsutil v0.1.6 h1:K7wR+EvqQT1Nn7jAKs3dKsGtUykPD2OYlCicv4/tUf8= -github.com/antlabs/wsutil v0.1.6/go.mod h1:7ec5eUM7nmKW+Oi6F1I58iatOeL9k+yIsfOh1zh910g= +github.com/antlabs/wsutil v0.1.7 h1:DVxFaS20mw16CMc11EjBIlkZQtcs+X0I1DI/J6l/AoE= +github.com/antlabs/wsutil v0.1.7/go.mod h1:7ec5eUM7nmKW+Oi6F1I58iatOeL9k+yIsfOh1zh910g= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pawelgaczynski/giouring v0.0.0-20230826085535-69588b89acb9 h1:Cu/CW2nKeqXinVjf5Bq1FeBD4jWG/msC5UazjjgAvsU= diff --git a/task_stream.go b/task_stream.go index 2c08b67..e16cd4e 100644 --- a/task_stream.go +++ b/task_stream.go @@ -31,6 +31,13 @@ func (t *taskStream) loop() { cb() } } + +func newTaskStream() *taskStream { + t := &taskStream{} + t.init() + return t +} + func (t *taskStream) init() { t.streamChan = make(chan func() bool, runtime.NumCPU()) go t.loop()