Skip to content

Commit

Permalink
Merge pull request #16 from antlabs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
guonaihong authored Jan 28, 2024
2 parents a8db72b + c989233 commit 627d9ea
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 48 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/autobahn.yml

This file was deleted.

62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 5 additions & 5 deletions conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
7 changes: 7 additions & 0 deletions task_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 627d9ea

Please sign in to comment.