From 60b9f573d9b9514d0e579c5fde88a34f212d9d20 Mon Sep 17 00:00:00 2001 From: Cyro Date: Mon, 11 Mar 2024 17:03:08 -0500 Subject: [PATCH] Update README with new description & graph --- README.md | 128 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index ae09d79..437e8b0 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,9 @@ Simply drop the mod into your `rml_mods` folder within the Resonite directory an # How do we solve this? -* Move the FullBatch to process outside of the encoding loop - - While the FullBatch is encoding, save all other messages (aside from stream messages) - - When the FullBatch is done, send it and then send all other packets behind it - - This ensures that streams (aka the stuff that carries your voice and movement data) don't get interrupted +* Move the StreamMessage processing to it's own exclusive thread + - This ensures that streams (aka the stuff that carries your voice and movement data) don't get interrupted by a FullBatch encode + - All other reliable packets stay on the default queue and are unaffected # How does it work? @@ -28,80 +27,97 @@ I'm glad you didn't ask! Here's a massive MermaidJS diagram for your viewing ple ```mermaid --- -title: Packet encoding +title: How packets are processed normally --- %%{ init: { 'flowchart': { 'curve': 'monotoneX' } } }%% graph LR - subgraph Queues - QueuedReliable[(Queued Reliable\npackets)] - QueuedFulls[(Queued FullBatch\npackets)] + style Queue fill:#48392A,stroke:#E69E50,stroke-width:2px + subgraph Queue[Queue packets to send] + direction LR + NewPacket[New packet to send] + Store[Store in queue] + PacketQueue[(Packet Queue)] + + + NewPacket --> Store --x PacketQueue end - subgraph FullBatch Processing Loop - StartProcessing[Start Processing\nIsProcessing = true] - ProcessFull[Process FullBatch] - FullQueueEmpty{FullBatch queue\nempty?} - Wait[Wait for new FullBatches] - - StartProcessing --> ProcessFull - ProcessFull -.-|Takes one| QueuedFulls - linkStyle 1 stroke:#E69E50,stroke-width:5px - ProcessFull --> FullQueueEmpty - - FullQueueEmpty -->|Yes| Wait - %%linkStyle 3 stroke:#59EB5C - FullQueueEmpty-->|No| StartProcessing - %%linkStyle 4 stroke:#FF7676 + + style ProcessLoop fill:#484A2C,stroke:#F8F770,stroke-width:2px + subgraph ProcessLoop[Packet Processing Loop] + While[While queue isn't empty] + Take[Take one from queue] + Encode[Wait for encode] + Transmit(Transmit packet 📡) + + + While --> Take + Take --> Encode --> Transmit --> While + PacketQueue -.->|Takes one| Take + linkStyle 6 stroke:#E69E50,stroke-width:4px end +``` + +```mermaid +--- +title: How packets are processed with Outflow +--- +%%{ init: { 'flowchart': { 'curve': 'monotoneX' } } }%% +graph LR + style Queue fill:#284C5D,stroke:#61D1FA,stroke-width:2px + subgraph Queue[Queue packets to send] + direction LR + PacketQueue[(Packet Queue)] + StreamQueue[(Stream Packet\nQueue)] - - New((New Reliable Packet)) - MessagesQueued{Are messages\nqueued to send?} - Flush[Flush queue] - ShouldQueue{Should packet queue?} - SetProcessing(IsProcessing = true) + NewPacket[New packet to send] + Store[Store in normal queue] + IsStream{Is StreamMessage?} + StoreStream[Store in stream queue] - QueueFull[Queue FullBatch] - QueueReliable[Queue Reliable] - Next[Next packet] + + NewPacket --> IsStream + IsStream -->|No| Store --x PacketQueue + linkStyle 1,2 stroke:#FF7676 + IsStream -->|Yes| StoreStream --x StreamQueue + linkStyle 3,4 stroke:#59EB5C + end - New --> MessagesQueued - MessagesQueued -->|Yes| Flush --> ShouldQueue - linkStyle 6,7 stroke:#59EB5C - MessagesQueued -->|No| ShouldQueue - linkStyle 8 stroke:#FF7676 - Conditions>Packets queue when:\nIsProcessing is true\nAND\nThe packet is not a stream\nOR\nThe packet is a FullBatch\n] -.- ShouldQueue + style ProcessLoop fill:#484A2C,stroke:#F8F770,stroke-width:2px + subgraph ProcessLoop[Packet Processing Loop] + While[While queue isn't empty] + Take[Take one from queue] + Encode[Wait for encode] + Transmit(Transmit packet 📡) - Flush -.-|Takes all| QueuedReliable - linkStyle 10 stroke:#59EB5C - ShouldQueue -->|Is FullBatch| QueueFull - linkStyle 11 stroke:#61D1FA + While --> Take + Take --> Encode --> Transmit --> While + PacketQueue -.->|Takes one| Take + linkStyle 9 stroke:#E69E50,stroke-width:4px + end - ShouldQueue -->|FullBatches are Processing\n&\nIs not StreamMessage| QueueReliable - linkStyle 12 stroke:#F8F770 - - QueueReliable --> SetProcessing --> Next - linkStyle 13,14 stroke:#F8F770 - ShouldQueue -->|Is StreamMessage| Next - linkStyle 15 stroke:#BA64F2 - QueueFull --> Next - linkStyle 16 stroke:#61D1FA + style StreamProcessLoop fill:#492F64,stroke:#BA64F2,stroke-width:2px + subgraph StreamProcessLoop[Stream Packet Processing Loop] + WhileStream[While queue isn't empty] + TakeStream[Take one from queue] + EncodeStream[Wait for encode] + TransmitStream(Transmit packet 📡) - QueueFull -.-x|Inserts| QueuedFulls - linkStyle 17 stroke:#61D1FA - QueueReliable -.-x|Inserts| QueuedReliable - linkStyle 18 stroke:#F8F770 + WhileStream --> TakeStream + TakeStream --> EncodeStream --> TransmitStream --> WhileStream + StreamQueue -.->|Takes one| TakeStream + linkStyle 14 stroke:#BA64F2,stroke-width:4px + end ``` - # Why isn't this in the game by default? I get this question a lot about some of my mods, so I want to go a little bit into detail about why it seems like modders can do all of these amazing things when the YDMS Team can't.