* MM-21012: Revamp websocket implementation We replace the old gorilla/websocket implementation with the gobwas/ws library. The gorilla library was in maintenance mode and had a high level API due to which we cannot use that for situations where a large number of concurrent connections needs to be supported. The ws library is a very low-level library that allows us to work with raw net.Conns. We make several improvements: - We completely remove the reader goroutines, and instead replace them with a manual epoll implementation which sends off messages to be read when it receives any data on the connection. This lets us scale to a much larger number of connections. - The reader buffer is eliminated, because we directly read from the connection now. https://mattermost.atlassian.net/browse/MM-21012 ```release-notes Improved the websocket implementation by using epoll manually to read from a websocket. As a result, the number of goroutines is expected to go down by half. ``` * fix tests * fix shadowing errors * final changes * windows support! * Remove pointer to waitgroup * Fix edge case * Trigger CI * Trigger CI Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
55 строки
1.6 KiB
Makefile
55 строки
1.6 KiB
Makefile
BENCH ?=.
|
|
BENCH_BASE?=master
|
|
|
|
clean:
|
|
rm -f bin/reporter
|
|
rm -fr autobahn/report/*
|
|
|
|
bin/reporter:
|
|
go build -o bin/reporter ./autobahn
|
|
|
|
bin/gocovmerge:
|
|
go build -o bin/gocovmerge github.com/wadey/gocovmerge
|
|
|
|
.PHONY: autobahn
|
|
autobahn: clean bin/reporter
|
|
./autobahn/script/test.sh --build --follow-logs
|
|
bin/reporter $(PWD)/autobahn/report/index.json
|
|
|
|
.PHONY: autobahn/report
|
|
autobahn/report: bin/reporter
|
|
./bin/reporter -http localhost:5555 ./autobahn/report/index.json
|
|
|
|
test:
|
|
go test -coverprofile=ws.coverage .
|
|
go test -coverprofile=wsutil.coverage ./wsutil
|
|
go test -coverprofile=wsfalte.coverage ./wsflate
|
|
# No statemenets to cover in ./tests (there are only tests).
|
|
go test ./tests
|
|
|
|
cover: bin/gocovmerge test autobahn
|
|
bin/gocovmerge ws.coverage wsutil.coverage wsflate.coverage autobahn/report/server.coverage > total.coverage
|
|
|
|
benchcmp: BENCH_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
|
|
benchcmp: BENCH_OLD:=$(shell mktemp -t old.XXXX)
|
|
benchcmp: BENCH_NEW:=$(shell mktemp -t new.XXXX)
|
|
benchcmp:
|
|
if [ ! -z "$(shell git status -s)" ]; then\
|
|
echo "could not compare with $(BENCH_BASE) – found unstaged changes";\
|
|
exit 1;\
|
|
fi;\
|
|
if [ "$(BENCH_BRANCH)" == "$(BENCH_BASE)" ]; then\
|
|
echo "comparing the same branches";\
|
|
exit 1;\
|
|
fi;\
|
|
echo "benchmarking $(BENCH_BRANCH)...";\
|
|
go test -run=none -bench=$(BENCH) -benchmem > $(BENCH_NEW);\
|
|
echo "benchmarking $(BENCH_BASE)...";\
|
|
git checkout -q $(BENCH_BASE);\
|
|
go test -run=none -bench=$(BENCH) -benchmem > $(BENCH_OLD);\
|
|
git checkout -q $(BENCH_BRANCH);\
|
|
echo "\nresults:";\
|
|
echo "========\n";\
|
|
benchcmp $(BENCH_OLD) $(BENCH_NEW);\
|
|
|