Part two of the refterm live stream is now available on YouTube - "Slow Code Isolation":https://youtu.be/lStYLF6Us_Q
-
-
Replying to @cmuratori
[1/2] Dumb question: Is the buffer locked? As far as I can see, a circular buffer can be completely thread-safe, while only locking writes during reads (or writes if there are multiple writers) if you can begin a write and bump the tail as an atomic action.
2 replies 0 retweets 0 likes -
Replying to @Benjipede
In keeping with the "this program is not optimized" statement of refterm, there are no threads in refterm! So the buffer doesn't have to be locked.
1 reply 0 retweets 0 likes -
Replying to @cmuratori @Benjipede
In general, unless you bypassed the kernel or maybe did a complete conhost implementation, etc., I'm not sure a terminal program on Windows can receive data fast enough to warrant using multiple threads :( I wish it weren't so, but, that seems to be the state of it.
1 reply 0 retweets 0 likes -
Replying to @cmuratori
[1/*] Thanks. So you ask for Windows to write to the buffer at certain points rather than having Windows just write, when it wants?
2 replies 0 retweets 0 likes -
Replying to @Benjipede @cmuratori
[2/*] The reason I am asking, is that I am making changes to a multithreaded data reception system and it is clearly making multiple unnecessary copies. It has queue that buffers packets, with metadata and data, on one thread and then a pure data buffer on another.
1 reply 0 retweets 0 likes -
Replying to @Benjipede @cmuratori
[3/*] The second thread then pulls from the queue, when it wants. The meta data and data obviously has to be separated, but as I see it, the first thread could simply put data directly into the buffer rather than into a queue. Maybe it shouldn't even be to be threaded this way?
2 replies 0 retweets 0 likes -
Replying to @Benjipede
It depends a lot on what you are doing. In general, you want the side with the knowledge about where the information should go to decide where it goes, and the other side to simply look for an ack.
1 reply 0 retweets 1 like -
Replying to @cmuratori @Benjipede
Without more knowledge of your specific problem it's hard for me to recommend a particular solution, but one thing I might recommend doing if you are trying to understand designs like this is to read up on io_uring.
1 reply 0 retweets 1 like -
Replying to @cmuratori @Benjipede
io_uring is an example of a system where you don't lock memory, you just have one side writing pointers into a ring buffer of where it wants to receive data, and the other side filling out that data and writing responses into another ring buffer.
1 reply 0 retweets 1 like
Nobody locks anything, and nobody copies any data.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.