summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2018-11-13 13:51:25 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2018-11-13 13:51:25 -0800
commit6684559cd9b8a96da29c7a59c8d787918a4171f9 (patch)
tree194d835e187f6906629453438a88b36da145e6fa /service
parent4ed7d20a4880a168a447eb0b5d02b3c643ab0cff (diff)
downloadinfinitytier-6684559cd9b8a96da29c7a59c8d787918a4171f9.tar.gz
infinitytier-6684559cd9b8a96da29c7a59c8d787918a4171f9.zip
More Mac tap improvements and threading efficiency improvements.
Diffstat (limited to 'service')
-rw-r--r--service/OneService.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp
index bf24466d..1351cbfb 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -472,6 +472,7 @@ public:
unsigned int _tertiaryPort;
volatile unsigned int _udpPortPickerCounter;
+ unsigned long _incomingPacketConcurrency;
std::vector<OneServiceIncomingPacket *> _incomingPacketMemoryPool;
BlockingQueue<OneServiceIncomingPacket *> _incomingPacketQueue;
std::vector<std::thread> _incomingPacketThreads;
@@ -606,7 +607,8 @@ public:
_ports[1] = 0;
_ports[2] = 0;
- for(long t=0;t<std::max((long)1,(long)std::thread::hardware_concurrency());++t) {
+ _incomingPacketConcurrency = std::max((unsigned long)1,std::min((unsigned long)16,(unsigned long)std::thread::hardware_concurrency()));
+ for(long t=0;t<_incomingPacketConcurrency;++t) {
_incomingPacketThreads.push_back(std::thread([this]() {
OneServiceIncomingPacket *pkt = nullptr;
for(;;) {
@@ -1918,7 +1920,7 @@ public:
pkt->size = (unsigned int)len;
ZT_FAST_MEMCPY(pkt->data,data,len);
- _incomingPacketQueue.postWait(pkt,64);
+ _incomingPacketQueue.postLimit(pkt,16 * _incomingPacketConcurrency);
}
inline void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success)