v2.3.0
版本发布时间: 2023-07-01 22:14:23
panjf2000/gnet最新发布版本:v2.5.0(2024-04-22 22:42:15)
🚀 Features
- feat: implement gnet on Windows (#461)
🛩 Enhancements
- build: add NetBSD and OpenBSD supports 9790927c31313d945d39866fba6fc1aa448138c4
- opt: make use of the inheritance of file status flags on BSD-like OS d98706e6175d9f547d57d4f1a295173328483876
- opt: rearrange the matrix and map of connections e3083990fb327198e2de3f17f1b6f1acfda73538
- internal/math: fix a corner case for IsPowerOfTwo (#476)
- opt: improve comments on Conn and test cases (#471)
- opt: mitigate big map issue of connections when garbage collecting (#460)
- opt: use the std math/bits routine to count the bit length (#437)
- opt: refine the SockaddrToTCPOrUnixAddr and SockaddrToUDPAddr abcc0315dceef8418bb451306f1ade47d3de370d
- opt: prepend [gnet] prefix to every log entry 650f731a92f128a3b16f05c24615dc4f25ca2ab8
- opt: set up the PanicHandler and Logger for pkg/pool/goroutine 222a3952e25e500a089f07f7242b3e7211a1d9c4
🐛 Bugfixes
- bug: fix the data race among asynchronous methods daffb4efa39923be6ee1d6b00c6d21f69cd3b079
- bug: fix the data race in test on Windows (#472)
- bug: replace the global logger with custom logger for client on Windows dd46b082ea0cb200b6bfa76790a35001c710fd9e
- bug: invoke the callback whether the connection is open or not (#466)
- bug: clean up the inner buffer after read event (#445)
- bug: fix the nil panic in conn.Flush() and increase the code coverage 0f41b37dc7a28d0546cd542fa392fe409bfb3667
- bug: fix the memory leak of linked-list-buffer 4b6dfdc6f26514cd288b18cbb4f7a659f93c9df5
- bug: fix the compile error on FreeBSD with 32-bit 72b6e726ce32f6bc3aeb22fb9bb153ff469e9ffa
- bug & feat: replace the global default logger with custom logger 3c66bced864ee4ff6d6f68cb76f9fbd6b4e6e32a
📚 Documentation
- chore: update the info of techempower.com b3411039e619844a56aa7986cbef68c1bf59e1c0
- doc: update the minimum required version of Go a9c26387627c29d98c5fbb1d42172851fa894b76
- doc: update READMEs about supported platforms 88ed242adae730cbb20949d20dcb2dc1daa252fb
🧳 Misc
- chore: delete the unused code in pkg/buffer/ring bdbb661682104076216de19ff743e2d327de5dc2
- chore: code cleanup 9ff529b8438b60b6580576349f4993db2c46386f
- opt: rename eventloop.closeConn to eventloop.close 7c9a61a5736c244fca14346e8b10f7dc83b81af1
- chore: add test for Engine.CountConnections b4931079ba57206971681fa292b088b80bac86c1
- chore: print a debugging log about logging level when client starts bdda3bfbd8a5e2e2ad55706facef035797301912
- chore: update copyright info ebc191ee2f130d21bef444e8fe20b4e219affc97
- chore: bump ants to v2.7.3 edb9318f91697817b71791b691ba9a763c63672f
- chore: fix the lint issues edffef890e0ab47fde4b6eec669eb0fc93fb559c
- chore: add more test cases for custom protocol testing deea03f14661366fc112da74b7df89fe889f67d7
❇️ Notices
The two major updates in this release candidate are #460 and #461.
We introduced a new data structure matrix
in #460 to displace the default map
for managing connections internally, with the help of this new data structure, we can eliminate the pointers in map
and store connections in the form of a matrix (an array of slices), which will significantly reduce GC (Garbage Collection) latency:
goos: darwin
goarch: arm64
pkg: github.com/panjf2000/gnet/v2
│ old │ new │
│ sec/op │ sec/op vs base │
GC4El100k/Run-4-eventloop-100000-10 30.74m ± 3% 19.68m ± 10% -35.98% (p=0.000 n=10)
GC4El200k/Run-4-eventloop-200000-10 63.64m ± 3% 38.16m ± 11% -40.04% (p=0.000 n=10)
GC4El500k/Run-4-eventloop-500000-10 177.28m ± 8% 95.21m ± 4% -46.29% (p=0.000 n=10)
geomean 70.26m 41.51m -40.92%
│ old │ new │
│ B/op │ B/op vs base │
GC4El100k/Run-4-eventloop-100000-10 27.50 ± 35% 25.50 ± 33% ~ (p=0.423 n=10)
GC4El200k/Run-4-eventloop-200000-10 27.50 ± 53% 20.50 ± 66% ~ (p=0.642 n=10)
GC4El500k/Run-4-eventloop-500000-10 16.00 ± ? 18.00 ± ? ~ (p=0.357 n=10)
geomean 22.96 21.11 -8.04%
│ old │ new │
│ allocs/op │ allocs/op vs base │
GC4El100k/Run-4-eventloop-100000-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
GC4El200k/Run-4-eventloop-200000-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
GC4El500k/Run-4-eventloop-500000-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
geomean ² +0.00% ²
¹ all samples are equal
² summaries must be >0 to compute geomean
The more connections there are, the more pronounced the effect.
While we have performed sufficient testing on matrix
, we are still using map
as the default connection storage in this RC version for the sake of caution, but you can enable the new data structure by specifying build tags: -tags=gc_opt. This can be considered as a precautionary measure so that in case matrix
has any unexpected bugs, you can quickly fall back to the default map
. We will consider promoting matrix
to be the default storage for connections in a subsequent official release.
Another significant leap is #461, you can now run gnet
on Windows, it should be noted that the Windows version of gnet
is intended for development purposes and is not recommended for use in production.
Full Changelog: https://github.com/panjf2000/gnet/compare/v2.2.0...v2.3.0
Thanks to all these contributors: @0-haha, @GXKe, @gocurr, @jinxing3114 and @panjf2000 for making this release possible.