Cuberite Forum
Possible packet improvements? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Possible packet improvements? (/thread-1285.html)



Possible packet improvements? - SamJBarney - 12-23-2013

How is MCServer sending packets at this moment? Are they being queued up and sent after the tick has happened, or are they being sent as soon as something happens that needs them?


RE: Possible packet improvements? - xoft - 12-23-2013

The packet is written to a buffer when it is "sent" by the cClientHandle / cProtocol classes. Then another thread is notified that outgoing data is ready, and that thread then takes care of sending as much data as possible to the client. See for example the cProtocol172::SendData() function, that is called to send each packet's raw data, it calls cClientHandle::SendData(), which queues the outgoing data in two buffers (a fast ringbuffer and a dynamically-allocated overflow buffer, then it notifies the cServer::cNotifyWriteThread that it should send the data for this client.


RE: Possible packet improvements? - SamJBarney - 12-23-2013

Do you think there might be any benefit to queueing up block changes by chunk and then sending them with Multi Block Change packet after the tick is done?


RE: Possible packet improvements? - xoft - 12-23-2013

I think that is already done now, let me check again.

Yup, that is already done, cChunk::m_PendingSendBlocks is the per-chunk queue for the changes.


RE: Possible packet improvements? - SamJBarney - 12-23-2013

Ok. Anyone got any ideas on how to make packet handling better?


RE: Possible packet improvements? - xoft - 12-23-2013

Why, do you have an issue with its current state? I think it's good enough.


RE: Possible packet improvements? - SamJBarney - 12-23-2013

Well, I can't remember if this was part of the AI development or the mob spawning merge, but you mentioned that the packet handling was slow and could be better. I'm trying to find that conversation now.