←back to thread

261 points tosh | 4 comments | | HN request time: 0.001s | source
1. akira2501 ◴[] No.42068280[source]
> A single 1080p raw video frame would be 1080 * 1920 * 1.5 = 3110.4 KB in size

They seem to not understand the fundamentals of what they're working on.

> Chromium's WebSocket implementation, and the WebSocket spec in general, create some especially bad performance pitfalls.

You're doing bulk data transfers into a multiplexed short messaging socket. What exactly did you expect?

> However there's no standard interface for transporting data over shared memory.

Yes there is. It's called /dev/shm. You can use shared memory like a filesystem, and no, you should not be worried about user/kernel space overhead at this point. It's the obvious solution to your problem.

> Instead of the typical two-pointers, we have three pointers in our ring buffer:

You can use two back to back mmap(2) calls to create a ringbuffer which avoids this.

replies(3): >>42068564 #>>42068966 #>>42069413 #
2. Scaevolus ◴[] No.42068564[source]
It's pretty funny that they assumed that memory copying was the limiting factor when they're pushing a mere 150MB/s around instead of the various websocket overheads, then jumped right into over-engineering a zero copy ring buffer. I get it, but come on!

>50 GB/s of memory bandwidth is common nowadays[1], and will basically never be the bottleneck for 1080P encoding. Zero copy matters when you're doing something exotic, like Netflix pushing dozens of GB/s from a CDN node.

[1]: https://lemire.me/blog/2024/01/18/how-much-memory-bandwidth-...

3. anonymous344 ◴[] No.42068966[source]
well someone will feel like an idiot after reading your facts. This is why education and experience is important. Not just React/rust course and then you are full stack senior :D
4. didip ◴[] No.42069413[source]
I agree with you. The moment they said shared memory, I was thinking /dev/shm. Lots of programming languages have libraries to /dev/shm already.

And since it behaves like filesystem, you can swap it with real filesystem during testing. Very convenient.

I am curious if they tried this already or not and if they did, what problems did they encounter?