stream/buffer: Reduces map lookups by using key struct (#1309)

* stream/buffer: Adds key map optimisation (cherry-pick)

* stream/buffer: Add buffer to DataHandler intermediary. Add field InitialUpdate bool to toggle when first update is seen for initial sync.

* whoops

* buffer: Add difference benchmarks for reference

* glorious: nits (reverting out of context changes)

* RM unused error that will be used later

* purge: benchmark

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-08-21 16:28:38 +10:00
committed by GitHub
parent f8024e1ee7
commit a440fab4f3
4 changed files with 51 additions and 58 deletions

View File

@@ -15,7 +15,7 @@ import (
)
const (
defaultJobBuffer = 1000
defaultJobBuffer = 5000
// defaultTrafficPeriod defines a period of pause for the traffic monitor,
// as there are periods with large incoming traffic alerts which requires a
// timer reset, this limits work on this routine to a more effective rate
@@ -62,7 +62,7 @@ func SetupGlobalReporter(r Reporter) {
func New() *Websocket {
return &Websocket{
Init: true,
DataHandler: make(chan interface{}),
DataHandler: make(chan interface{}, defaultJobBuffer),
ToRoutine: make(chan interface{}, defaultJobBuffer),
TrafficAlert: make(chan struct{}),
ReadMessageErrors: make(chan error),