mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
* refactor profiling function names
* utp link layer make ping less active, pre-emptive pump faster
This commit is contained in:
parent
88abe28cc1
commit
2be3401e08
5 changed files with 16 additions and 19 deletions
|
@ -78,7 +78,7 @@ namespace llarp
|
||||||
uint64_t chances)
|
uint64_t chances)
|
||||||
{
|
{
|
||||||
if(fails > 0 && (fails + success) >= chances)
|
if(fails > 0 && (fails + success) >= chances)
|
||||||
return (success / fails) > 2;
|
return (success / fails) > 1;
|
||||||
if(success == 0)
|
if(success == 0)
|
||||||
return fails < chances;
|
return fails < chances;
|
||||||
return true;
|
return true;
|
||||||
|
@ -135,7 +135,7 @@ namespace llarp
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::MarkTimeout(const RouterID& r)
|
Profiling::MarkConnectTimeout(const RouterID& r)
|
||||||
{
|
{
|
||||||
lock_t lock(&m_ProfilesMutex);
|
lock_t lock(&m_ProfilesMutex);
|
||||||
m_Profiles[r].connectTimeoutCount += 1;
|
m_Profiles[r].connectTimeoutCount += 1;
|
||||||
|
@ -143,7 +143,7 @@ namespace llarp
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::MarkSuccess(const RouterID& r)
|
Profiling::MarkConnectSuccess(const RouterID& r)
|
||||||
{
|
{
|
||||||
lock_t lock(&m_ProfilesMutex);
|
lock_t lock(&m_ProfilesMutex);
|
||||||
m_Profiles[r].connectGoodCount += 1;
|
m_Profiles[r].connectGoodCount += 1;
|
||||||
|
|
|
@ -75,10 +75,10 @@ namespace llarp
|
||||||
LOCKS_EXCLUDED(m_ProfilesMutex);
|
LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||||
|
|
||||||
void
|
void
|
||||||
MarkTimeout(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
MarkConnectTimeout(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||||
|
|
||||||
void
|
void
|
||||||
MarkSuccess(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
MarkConnectSuccess(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||||
|
|
||||||
void
|
void
|
||||||
MarkPathFail(path::Path* p) LOCKS_EXCLUDED(m_ProfilesMutex);
|
MarkPathFail(path::Path* p) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||||
|
|
|
@ -65,7 +65,7 @@ struct TryConnectJob
|
||||||
void
|
void
|
||||||
Success()
|
Success()
|
||||||
{
|
{
|
||||||
router->routerProfiling().MarkSuccess(rc.pubkey);
|
router->routerProfiling().MarkConnectSuccess(rc.pubkey);
|
||||||
router->FlushOutboundFor(rc.pubkey, link);
|
router->FlushOutboundFor(rc.pubkey, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ struct TryConnectJob
|
||||||
Attempt();
|
Attempt();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
router->routerProfiling().MarkTimeout(rc.pubkey);
|
router->routerProfiling().MarkConnectTimeout(rc.pubkey);
|
||||||
if(router->routerProfiling().IsBad(rc.pubkey))
|
if(router->routerProfiling().IsBad(rc.pubkey))
|
||||||
{
|
{
|
||||||
if(!router->IsBootstrapNode(rc.pubkey))
|
if(!router->IsBootstrapNode(rc.pubkey))
|
||||||
|
@ -561,7 +561,7 @@ namespace llarp
|
||||||
router->dht()->impl->Nodes()->PutNode(rc);
|
router->dht()->impl->Nodes()->PutNode(rc);
|
||||||
|
|
||||||
// mark success in profile
|
// mark success in profile
|
||||||
router->routerProfiling().MarkSuccess(pk);
|
router->routerProfiling().MarkConnectSuccess(pk);
|
||||||
|
|
||||||
// this was an outbound establish job
|
// this was an outbound establish job
|
||||||
if(ctx->establish_job)
|
if(ctx->establish_job)
|
||||||
|
@ -674,7 +674,7 @@ namespace llarp
|
||||||
if(results.size() == 0)
|
if(results.size() == 0)
|
||||||
{
|
{
|
||||||
if(!IsServiceNode())
|
if(!IsServiceNode())
|
||||||
routerProfiling().MarkTimeout(remote);
|
routerProfiling().MarkConnectTimeout(remote);
|
||||||
}
|
}
|
||||||
for(const auto &result : results)
|
for(const auto &result : results)
|
||||||
{
|
{
|
||||||
|
|
|
@ -245,7 +245,6 @@ namespace llarp
|
||||||
if(itr->second.IsExpired(now))
|
if(itr->second.IsExpired(now))
|
||||||
{
|
{
|
||||||
llarp::LogInfo("lookup for ", itr->first, " timed out");
|
llarp::LogInfo("lookup for ", itr->first, " timed out");
|
||||||
router->routerProfiling().MarkTimeout(itr->first);
|
|
||||||
itr = m_PendingRouters.erase(itr);
|
itr = m_PendingRouters.erase(itr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -852,7 +851,6 @@ namespace llarp
|
||||||
bool
|
bool
|
||||||
Endpoint::HandleGotRouterMessage(const llarp::dht::GotRouterMessage* msg)
|
Endpoint::HandleGotRouterMessage(const llarp::dht::GotRouterMessage* msg)
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if(msg->R.size() == 1)
|
if(msg->R.size() == 1)
|
||||||
{
|
{
|
||||||
auto itr = m_PendingRouters.find(msg->R[0].pubkey);
|
auto itr = m_PendingRouters.find(msg->R[0].pubkey);
|
||||||
|
@ -866,12 +864,9 @@ namespace llarp
|
||||||
job->hook = nullptr;
|
job->hook = nullptr;
|
||||||
job->rc = msg->R[0];
|
job->rc = msg->R[0];
|
||||||
llarp_nodedb_async_verify(job);
|
llarp_nodedb_async_verify(job);
|
||||||
const RouterID k(msg->R[0].pubkey);
|
|
||||||
m_Router->routerProfiling().MarkSuccess(k);
|
|
||||||
m_PendingRouters.erase(itr);
|
m_PendingRouters.erase(itr);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -229,7 +229,9 @@ namespace llarp
|
||||||
bool
|
bool
|
||||||
Session::ShouldPing() const
|
Session::ShouldPing() const
|
||||||
{
|
{
|
||||||
auto dlt = parent->Now() - lastActive;
|
if(state != eSessionReady)
|
||||||
|
return false;
|
||||||
|
const auto dlt = parent->Now() - lastActive;
|
||||||
return dlt >= 10000;
|
return dlt >= 10000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,7 +256,7 @@ namespace llarp
|
||||||
if(sendq.size() >= MaxSendQueueSize)
|
if(sendq.size() >= MaxSendQueueSize)
|
||||||
return false;
|
return false;
|
||||||
// preemptive pump
|
// preemptive pump
|
||||||
if(sendq.size() >= MaxSendQueueSize / 2)
|
if(sendq.size() >= MaxSendQueueSize / 8)
|
||||||
PumpWrite();
|
PumpWrite();
|
||||||
size_t sz = buf.sz;
|
size_t sz = buf.sz;
|
||||||
byte_t* ptr = buf.base;
|
byte_t* ptr = buf.base;
|
||||||
|
@ -277,7 +279,7 @@ namespace llarp
|
||||||
bool
|
bool
|
||||||
Session::SendKeepAlive()
|
Session::SendKeepAlive()
|
||||||
{
|
{
|
||||||
if(state == eSessionReady)
|
if(ShouldPing())
|
||||||
{
|
{
|
||||||
DiscardMessage msg;
|
DiscardMessage msg;
|
||||||
std::array< byte_t, 128 > tmp;
|
std::array< byte_t, 128 > tmp;
|
||||||
|
@ -480,7 +482,7 @@ namespace llarp
|
||||||
LogError("keyed hash failed");
|
LogError("keyed hash failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ShortHash expected(ptr);
|
const ShortHash expected(ptr);
|
||||||
if(expected != digest)
|
if(expected != digest)
|
||||||
{
|
{
|
||||||
LogError("Message Integrity Failed: got ", digest, " from ", remoteAddr,
|
LogError("Message Integrity Failed: got ", digest, " from ", remoteAddr,
|
||||||
|
|
Loading…
Reference in a new issue