Closed ghost closed 4 years ago
I've thought about this a lot and the simplest solution seems to perform very good:
Something like that, I haven't thought about every detail but iterating 3 million sockets across 3 Sets takes less than 15% of the time syscalls take so that is a negligible cost (it can even go down to practially free if sockets are stored in sorted vectors, but sets are fine).
lexhultman@clr-9c9c4beff725453db9688b589234d573~/uWebSockets.js/uWebSockets/benchmarks $ ./broadcast_test 40 localhost 9001 0
Running benchmark now...
Iterations/second (40 clients): 2300.750000
Iterations/second (40 clients): 2308.000000
Iterations/second (40 clients): 2304.250000
Iterations/second (40 clients): 2300.000000
Iterations/second (40 clients): 2306.000000
Iterations/second (40 clients): 2303.500000
Iterations/second (40 clients): 2304.500000
Iterations/second (40 clients): 2305.500000
^C
alexhultman@clr-9c9c4beff725453db9688b589234d573~/uWebSockets.js/uWebSockets/benchmarks $ ./broadcast_test 40 localhost 9001 0
Running benchmark now...
Iterations/second (40 clients): 2712.250000
Iterations/second (40 clients): 2724.000000
Iterations/second (40 clients): 2719.250000
Iterations/second (40 clients): 2716.000000
New pubsub is currently 2300 vs. former 2700 however things can be optimized a lot. This implementation at least does things reasonably correct.
Tracking all issues with pub/sub
-> I have thought a lot about pub/sub and I have a few strategies I am considering,
Bugs:
914 <- one publish can resolve into many topics (such as wildcards)
937 <- yes, this is currently very broken
Status is currently very broken, and I do not know how relevant this support is right now anymore