aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_env.h
diff options
context:
space:
mode:
authorJozef Behran <jozuejozef@gmail.com>2019-04-14 15:56:38 -0500
committerParamat <paramat@users.noreply.github.com>2019-04-14 21:56:38 +0100
commit007ce24a111372ddd0d4d5a9fbe862cea430fa4b (patch)
treeaaeef90c98f3dc560587c75d631aaba2529660b0 /src/script/cpp_api/s_env.h
parent4d2ad7c2b2e91f8a0138fa583f28465278cf0802 (diff)
downloadminetest-007ce24a111372ddd0d4d5a9fbe862cea430fa4b.tar.gz
minetest-007ce24a111372ddd0d4d5a9fbe862cea430fa4b.tar.bz2
minetest-007ce24a111372ddd0d4d5a9fbe862cea430fa4b.zip
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.
Diffstat (limited to 'src/script/cpp_api/s_env.h')
0 files changed, 0 insertions, 0 deletions