ThePrimeagen / tyrone-biggums

Clearly a repo about websockets and their comparison...
Other
465 stars 56 forks source link

remove unnecessary task spawns #10

Closed pro465 closed 2 years ago

pro465 commented 2 years ago

i tried to make the rust program closer to its go version, not sure if it compiles yet...

pro465 commented 2 years ago

i made this pr because i found @ThePrimeagen referring to #8 as "hyperoptimized" and on wanting to optimize the go version too. but we wanted to test how go would compare against a more identical rust version, not two hyperoptimized programs with different structures tuned to the programming language's specific strengths, otherwise that would be basically @PlummersSoftwareLLC's primes benchmark, just with async context instead of primes

ThePrimeagen commented 2 years ago

reasonable change.

I am unsure how much different or closer this actually makes go / rust. Or if it will make any meaningful difference. Taking out one long running task seems less meaningful then the spawning of several small tasks.

In the go library used, gorilla, there appears to be at least 1 go routine that is executed per connection made, therefore attempting to compare the performance win / loss here may be too small in comparison to the rest of the program.

Therefore, i am fine merging it and will even run some small numbers just to see.

pro465 commented 2 years ago

@ThePrimeagen well the go version does not send sockets through channels, so i made the rust version same. i did not intend to optimize it, so whether it makes any difference does not matter here.