From: Oliver Kurth Date: Thu, 28 Mar 2019 19:43:00 +0000 (-0700) Subject: DnD performance tuning for Mac and Windows clients; not directly applicable X-Git-Tag: stable-11.0.0~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c760135f46eaf246612bc8632374966ed79ce9b2;p=thirdparty%2Fopen-vm-tools.git DnD performance tuning for Mac and Windows clients; not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h index db8d2b144..f439eb6ec 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h +++ b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h @@ -201,11 +201,11 @@ typedef struct DnDTransportBuffer { #define DND_TRANSPORT_PACKET_HEADER_SIZE (5 * sizeof(uint32)) #ifdef VMX86_HORIZON_VIEW /* - * For Horizon DnD, expand the message size to almost 1M, which is the - * mkscontrol message limitation. Leave 100 bytes for mkscontrol message - * overhead (message header + length of message name) + * For Horizon DnD, expand the message size to almost 16M, which provides + * better DnD Performance on text/rich text/image etc. dragging and dropping + * per current performance tuning. */ -#define DND_MAX_TRANSPORT_PACKET_SIZE ((1 << 20) - 100) +#define DND_MAX_TRANSPORT_PACKET_SIZE ((1 << 24) - 100) #else /* Close to 64k (maximum guestRpc message size). Leave some space for guestRpc header. */ #define DND_MAX_TRANSPORT_PACKET_SIZE ((1 << 16) - 100) diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.c b/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.c index 39b2638a2..e146e5141 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.c +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.c @@ -167,6 +167,17 @@ Bool DnDCPMsgV4_Serialize(DnDCPMsgV4 *msg, uint8 **packet, size_t *packetSize) +{ + return DnDCPMsgV4_SerializeWithInputPayloadSizeCheck( + msg, packet, packetSize, DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4); +} + + +Bool +DnDCPMsgV4_SerializeWithInputPayloadSizeCheck(DnDCPMsgV4 *msg, + uint8 **packet, + size_t *packetSize, + const uint32 maxPacketPayloadSize) { size_t payloadSize = 0; @@ -175,7 +186,7 @@ DnDCPMsgV4_Serialize(DnDCPMsgV4 *msg, ASSERT(packetSize); ASSERT(msg->hdr.binarySize >= msg->hdr.payloadOffset); - if (msg->hdr.binarySize <= DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4) { + if (msg->hdr.binarySize <= maxPacketPayloadSize) { /* * One single packet is enough for the message. For short message, the * payloadOffset should always be 0. @@ -184,8 +195,8 @@ DnDCPMsgV4_Serialize(DnDCPMsgV4 *msg, payloadSize = msg->hdr.binarySize; } else { /* For big message, payloadOffset means binary size we already sent out. */ - if (msg->hdr.binarySize - msg->hdr.payloadOffset > DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4) { - payloadSize = DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4; + if (msg->hdr.binarySize - msg->hdr.payloadOffset > maxPacketPayloadSize) { + payloadSize = maxPacketPayloadSize; } else { payloadSize = msg->hdr.binarySize - msg->hdr.payloadOffset; } diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.h b/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.h index bd4fc94b6..5d3ef7826 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.h +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.h @@ -244,6 +244,8 @@ DnDCPMsgPacketType DnDCPMsgV4_GetPacketType(const uint8 *packet, Bool DnDCPMsgV4_Serialize(DnDCPMsgV4 *msg, uint8 **packet, size_t *packetSize); +Bool DnDCPMsgV4_SerializeWithInputPayloadSizeCheck(DnDCPMsgV4 *msg, + uint8 **packet, size_t *packetSize, const uint32 maxPacketPayloadSize); Bool DnDCPMsgV4_UnserializeSingle(DnDCPMsgV4 *msg, const uint8 *packet, size_t packetSize); diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndRpcV4.hh b/open-vm-tools/services/plugins/dndcp/dnd/dndRpcV4.hh index 0d4bcf116..46e8b27d3 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndRpcV4.hh +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndRpcV4.hh @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -103,6 +103,8 @@ public: void AddRpcSentListener(DnDRpcListener *obj); void RemoveRpcSentListener(DnDRpcListener *obj); + void SetMaxTransportPacketSize(const uint32 size); + private: DnDCPTransport *mTransport; TransportInterfaceType mTransportInterface; diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc b/open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc index 59d637e5c..822af80dd 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -836,3 +836,16 @@ DnDRpcV4::RemoveRpcSentListener(DnDRpcListener *obj) { mUtil.RemoveRpcSentListener(obj); } + + +/** + * Set the max transport packet size of RPC messages. + * + * @param[in] size the new max packet size. + */ + +void +DnDRpcV4::SetMaxTransportPacketSize(const uint32 size) +{ + mUtil.SetMaxTransportPacketSize(size); +} diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.cpp b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.cpp index 60ee08996..cca5d9ed7 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.cpp +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.cpp @@ -53,7 +53,8 @@ extern "C" { RpcV4Util::RpcV4Util(void) : mVersionMajor(4), - mVersionMinor(0) + mVersionMinor(0), + mMaxTransportPacketPayloadSize(DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4) { DnDCPMsgV4_Init(&mBigMsgIn); DnDCPMsgV4_Init(&mBigMsgOut); @@ -177,7 +178,7 @@ RpcV4Util::SendMsg(RpcParams *params, DnDCPMsgV4_Init(&shortMsg); - if (binarySize > DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4) { + if (binarySize > mMaxTransportPacketPayloadSize) { /* * For big message, all information should be cached in mBigMsgOut * because multiple packets and sends are needed. @@ -335,7 +336,8 @@ RpcV4Util::SendMsg(DnDCPMsgV4 *msg) size_t packetSize = 0; bool ret = false; - if (!DnDCPMsgV4_Serialize(msg, &packet, &packetSize)) { + if (!DnDCPMsgV4_SerializeWithInputPayloadSizeCheck(msg, &packet, + &packetSize, mMaxTransportPacketPayloadSize)) { LOG(1, ("%s: DnDCPMsgV4_Serialize failed. \n", __FUNCTION__)); return false; } @@ -364,7 +366,12 @@ RpcV4Util::OnRecvPacket(uint32 srcId, const uint8 *packet, size_t packetSize) { - DnDCPMsgPacketType packetType = DnDCPMsgV4_GetPacketType(packet, packetSize); + DnDCPMsgPacketType packetType = DND_CP_MSG_PACKET_TYPE_INVALID; + + if (packetSize <= mMaxTransportPacketPayloadSize + DND_CP_MSG_HEADERSIZE_V4) { + packetType = DnDCPMsgV4_GetPacketType(packet, packetSize); + } + switch (packetType) { case DND_CP_MSG_PACKET_TYPE_SINGLE: HandlePacket(srcId, packet, packetSize); @@ -665,4 +672,27 @@ RpcV4Util::FireRpcSentCallbacks(uint32 cmd, } +/** + * Set the max transport packet size of RPC messages. + * + * @param[in] size the new max packet size. + */ + +void +RpcV4Util::SetMaxTransportPacketSize(const uint32 size) +{ + ASSERT(size > DND_CP_MSG_HEADERSIZE_V4); + + uint32 newProposedPayloadSize = size - DND_CP_MSG_HEADERSIZE_V4; + if (newProposedPayloadSize < DND_CP_PACKET_MAX_PAYLOAD_SIZE_V4) { + /* + * Reset the max transport packet payload size + * if the new size is stricter than the default one. + */ + mMaxTransportPacketPayloadSize = newProposedPayloadSize; + LOG(1, ("%s: The packet size is set to %u. \n", __FUNCTION__, + mMaxTransportPacketPayloadSize)); + } +} + diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.hpp b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.hpp index 7f978d6c6..6e38a75d0 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.hpp +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.hpp @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -84,6 +84,8 @@ public: bool AddRpcSentListener(const DnDRpcListener *obj); bool RemoveRpcSentListener(const DnDRpcListener *obj); + void SetMaxTransportPacketSize(const uint32 size); + private: void FireRpcReceivedCallbacks(uint32 cmd, uint32 src, uint32 session); void FireRpcSentCallbacks(uint32 cmd, uint32 dest, uint32 session); @@ -107,6 +109,7 @@ private: uint32 mMsgSrc; DblLnkLst_Links mRpcSentListeners; DblLnkLst_Links mRpcReceivedListeners; + uint32 mMaxTransportPacketPayloadSize; }; #endif // RPC_V4_UTIL_HPP