Closed evan-bradley closed 1 year ago
Patch coverage is 90.66%
of modified lines.
Files Changed | Coverage |
---|---|
client/internal/packagessyncer.go | 0.00% |
client/types/callbacks.go | ø |
server/httpconnection.go | 0.00% |
client/internal/mockserver.go | 85.71% |
server/serverimpl.go | 95.00% |
client/httpclient.go | 100.00% |
client/internal/clientcommon.go | 100.00% |
client/internal/httpsender.go | 100.00% |
client/internal/receivedprocessor.go | 100.00% |
server/callbacks.go | 100.00% |
... and 1 more |
:loudspeaker: Thoughts on this report? Let us know!.
Hint: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat is very useful for showing before/after benchmark comparison.
Here is what it produces for your benchmark results:
name old time/op new time/op delta
SendToClient-24 238µs ±50% 262µs ±33% ~ (p=0.690 n=5+5)
Looks like it is close, but could use a more stable execution environment for benchmarking. :-)
@evan-bradley opamp-go v0.9.0 released: https://github.com/open-telemetry/opamp-go/releases/tag/v0.9.0
The Gorilla websocket package states that only one concurrent write can be made to a connection at a time. The library will try to detect concurrent writes and will panic if it detects that one is happening.
We might see concurrent writes in two places:
OnConnectedFunc
.In my opinion it would make sense to prevent concurrent writes within the library to relieve the application from having to worry about this detail. This does necessitate a mutex per connection, but I don't see any significant performance impact from the mutexes.
Without the mutex in
wsConnection
:With the mutex:
This is a fairly rudimentary solution, but it does solve the issue I was seeing and is straightforward. I'm open to more sophisticated ways of managing the write concurrency if there's a deficiency with this approach.