summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-05 17:41:07 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-05 17:41:07 -0800
commit83c6b7ab3d79e67984d3c5a03c23010312161e90 (patch)
tree165839f5f6dfab6672692a35d70c8e57380852bd
parentba5008c3701d9621ef9ccfd9b864d5eed923a3c4 (diff)
downloadinfinitytier-83c6b7ab3d79e67984d3c5a03c23010312161e90.tar.gz
infinitytier-83c6b7ab3d79e67984d3c5a03c23010312161e90.zip
Use bigger UDP buffer on bigger x64 machines. Keep old value elsewhere since these are likely to be smaller boxes.
-rw-r--r--service/OneService.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp
index e0ead047..299d6697 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -422,6 +422,15 @@ struct TcpConnection
Mutex writeBuf_m;
};
+// Use a bigger buffer on AMD64 since these are likely to be bigger and
+// servers. Otherwise use a smaller buffer. This makes no difference
+// except under very high load.
+#if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__))
+#define ZT_UDP_DESIRED_BUF_SIZE 1048576
+#else
+#define ZT_UDP_DESIRED_BUF_SIZE 131072
+#endif
+
class OneServiceImpl : public OneService
{
public:
@@ -462,7 +471,7 @@ public:
}
_v4LocalAddress = InetAddress((uint32_t)0,port);
- _v4UdpSocket = _phy.udpBind((const struct sockaddr *)&_v4LocalAddress,reinterpret_cast<void *>(&_v4LocalAddress),131072);
+ _v4UdpSocket = _phy.udpBind((const struct sockaddr *)&_v4LocalAddress,reinterpret_cast<void *>(&_v4LocalAddress),ZT_UDP_DESIRED_BUF_SIZE);
if (_v4UdpSocket) {
struct sockaddr_in in4;
@@ -474,7 +483,7 @@ public:
if (_v4TcpListenSocket) {
_v6LocalAddress = InetAddress("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",16,port);
- _v6UdpSocket = _phy.udpBind((const struct sockaddr *)&_v6LocalAddress,reinterpret_cast<void *>(&_v6LocalAddress),131072);
+ _v6UdpSocket = _phy.udpBind((const struct sockaddr *)&_v6LocalAddress,reinterpret_cast<void *>(&_v6LocalAddress),ZT_UDP_DESIRED_BUF_SIZE);
struct sockaddr_in6 in6;
memset((void *)&in6,0,sizeof(in6));