minetest/src/network
Jozef Behran 007ce24a11 Various network performance improvements (#8125)
* Optimize packet construction functions

Some of the functions that construct packets in
connection.cpp are using a const reference to get the raw
packet data to package and others use a value passed
parameter to do that. The ones that use the value passed
parameter suffer from performance hit as the rather bulky
packet data gets a temporary copy when the parameter is
passed before it lands at its final destination inside the
newly constructed packet. The unnecessary temporary copy
hurts quite badly as the underlying class (SharedBuffer)
actually allocates the space for the data in the heap.

Fix the performance hit by converting all of these value
passed parameters to const references. I believe that this
is what the author of the relevant code actually intended
to do as there is a couple of packet construction helper
functions that already use a const reference to get the
raw data.

* Optimize packet sender thread class

Most of the data sending methods of the packet sender thread
class use a value passed parameter for the packet data to be
sent. This causes the rather bulky data to be allocated on
the heap and copied, slowing the packet sending down. Convert
these parameters to const references to avoid the performance
hit.

* Optimize packet receiver thread class

The packet receiver and processor thread class has many
methods (mostly packet handlers) that receive the packed data
by value. This causes a performance hit that is actually
worse than the one caused by the packet sender methods
because the packet is first handed to the processPacket
method which looks at the packet type stored in the header
and then delegates the actual handling to one of the
handlers. Both, processPacket and all the handlers get the
packet data by value, leading to at least two unnecessary
copies of the data (with malloc and all the slow bells and
whistles of bulky classes).

As there already is a few methods that use a const reference
parameter for the packet data, convert all this value passed
packets to const references.
2019-04-14 21:56:38 +01:00
..
address.cpp Attend to LINT sillyness (#8276) 2019-02-23 02:41:36 +00:00
address.h Disable confirmation dialog on localhost 2019-02-09 19:52:56 +01:00
clientopcodes.cpp Send only changed node metadata to clients instead of whole mapblock (#5268) 2018-12-04 20:37:48 +01:00
clientopcodes.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clientpackethandler.cpp Fix serialization of std::time_t by casting to u64 first (#8353) 2019-03-10 18:53:02 +00:00
CMakeLists.txt Initial Haiku support (#6568) 2017-10-30 08:17:43 +01:00
connection.cpp Various network performance improvements (#8125) 2019-04-14 21:56:38 +01:00
connection.h Various network performance improvements (#8125) 2019-04-14 21:56:38 +01:00
connectionthreads.cpp Various network performance improvements (#8125) 2019-04-14 21:56:38 +01:00
connectionthreads.h Various network performance improvements (#8125) 2019-04-14 21:56:38 +01:00
networkexceptions.h Network cleanup (#6302) 2017-08-24 08:28:54 +02:00
networkpacket.cpp Fix serialization of std::time_t by casting to u64 first (#8353) 2019-03-10 18:53:02 +00:00
networkpacket.h Fix serialization of std::time_t by casting to u64 first (#8353) 2019-03-10 18:53:02 +00:00
networkprotocol.h Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019) 2019-02-07 21:26:06 +00:00
peerhandler.h LINT fixes since recent tooling update 2019-03-14 12:30:13 +01:00
serveropcodes.cpp Send only changed node metadata to clients instead of whole mapblock (#5268) 2018-12-04 20:37:48 +01:00
serveropcodes.h C++ modernize: Pragma once (#6264) 2017-08-17 22:19:39 +02:00
serverpackethandler.cpp Optimize interaction distance checker (#8193) 2019-03-07 08:19:13 +01:00
socket.cpp Fix ipv6_server=true not accepting IPv4 connections on Windows (#7471) 2018-06-22 20:54:23 +02:00
socket.h Network cleanup (#6302) 2017-08-24 08:28:54 +02:00