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)
|
||||
{
|
||||
if(fails > 0 && (fails + success) >= chances)
|
||||
return (success / fails) > 2;
|
||||
return (success / fails) > 1;
|
||||
if(success == 0)
|
||||
return fails < chances;
|
||||
return true;
|
||||
|
@ -135,7 +135,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
Profiling::MarkTimeout(const RouterID& r)
|
||||
Profiling::MarkConnectTimeout(const RouterID& r)
|
||||
{
|
||||
lock_t lock(&m_ProfilesMutex);
|
||||
m_Profiles[r].connectTimeoutCount += 1;
|
||||
|
@ -143,7 +143,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
Profiling::MarkSuccess(const RouterID& r)
|
||||
Profiling::MarkConnectSuccess(const RouterID& r)
|
||||
{
|
||||
lock_t lock(&m_ProfilesMutex);
|
||||
m_Profiles[r].connectGoodCount += 1;
|
||||
|
|
|
@ -75,10 +75,10 @@ namespace llarp
|
|||
LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
|
||||
void
|
||||
MarkTimeout(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
MarkConnectTimeout(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
|
||||
void
|
||||
MarkSuccess(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
MarkConnectSuccess(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
|
||||
void
|
||||
MarkPathFail(path::Path* p) LOCKS_EXCLUDED(m_ProfilesMutex);
|
||||
|
|
|
@ -65,7 +65,7 @@ struct TryConnectJob
|
|||
void
|
||||
Success()
|
||||
{
|
||||
router->routerProfiling().MarkSuccess(rc.pubkey);
|
||||
router->routerProfiling().MarkConnectSuccess(rc.pubkey);
|
||||
router->FlushOutboundFor(rc.pubkey, link);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ struct TryConnectJob
|
|||
Attempt();
|
||||
return;
|
||||
}
|
||||
router->routerProfiling().MarkTimeout(rc.pubkey);
|
||||
router->routerProfiling().MarkConnectTimeout(rc.pubkey);
|
||||
if(router->routerProfiling().IsBad(rc.pubkey))
|
||||
{
|
||||
if(!router->IsBootstrapNode(rc.pubkey))
|
||||
|
@ -561,7 +561,7 @@ namespace llarp
|
|||
router->dht()->impl->Nodes()->PutNode(rc);
|
||||
|
||||
// mark success in profile
|
||||
router->routerProfiling().MarkSuccess(pk);
|
||||
router->routerProfiling().MarkConnectSuccess(pk);
|
||||
|
||||
// this was an outbound establish job
|
||||
if(ctx->establish_job)
|
||||
|
@ -674,7 +674,7 @@ namespace llarp
|
|||
if(results.size() == 0)
|
||||
{
|
||||
if(!IsServiceNode())
|
||||
routerProfiling().MarkTimeout(remote);
|
||||
routerProfiling().MarkConnectTimeout(remote);
|
||||
}
|
||||
for(const auto &result : results)
|
||||
{
|
||||
|
|
|
@ -245,7 +245,6 @@ namespace llarp
|
|||
if(itr->second.IsExpired(now))
|
||||
{
|
||||
llarp::LogInfo("lookup for ", itr->first, " timed out");
|
||||
router->routerProfiling().MarkTimeout(itr->first);
|
||||
itr = m_PendingRouters.erase(itr);
|
||||
}
|
||||
else
|
||||
|
@ -852,7 +851,6 @@ namespace llarp
|
|||
bool
|
||||
Endpoint::HandleGotRouterMessage(const llarp::dht::GotRouterMessage* msg)
|
||||
{
|
||||
bool success = false;
|
||||
if(msg->R.size() == 1)
|
||||
{
|
||||
auto itr = m_PendingRouters.find(msg->R[0].pubkey);
|
||||
|
@ -866,12 +864,9 @@ namespace llarp
|
|||
job->hook = nullptr;
|
||||
job->rc = msg->R[0];
|
||||
llarp_nodedb_async_verify(job);
|
||||
const RouterID k(msg->R[0].pubkey);
|
||||
m_Router->routerProfiling().MarkSuccess(k);
|
||||
m_PendingRouters.erase(itr);
|
||||
return true;
|
||||
}
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -229,7 +229,9 @@ namespace llarp
|
|||
bool
|
||||
Session::ShouldPing() const
|
||||
{
|
||||
auto dlt = parent->Now() - lastActive;
|
||||
if(state != eSessionReady)
|
||||
return false;
|
||||
const auto dlt = parent->Now() - lastActive;
|
||||
return dlt >= 10000;
|
||||
};
|
||||
|
||||
|
@ -254,7 +256,7 @@ namespace llarp
|
|||
if(sendq.size() >= MaxSendQueueSize)
|
||||
return false;
|
||||
// preemptive pump
|
||||
if(sendq.size() >= MaxSendQueueSize / 2)
|
||||
if(sendq.size() >= MaxSendQueueSize / 8)
|
||||
PumpWrite();
|
||||
size_t sz = buf.sz;
|
||||
byte_t* ptr = buf.base;
|
||||
|
@ -277,7 +279,7 @@ namespace llarp
|
|||
bool
|
||||
Session::SendKeepAlive()
|
||||
{
|
||||
if(state == eSessionReady)
|
||||
if(ShouldPing())
|
||||
{
|
||||
DiscardMessage msg;
|
||||
std::array< byte_t, 128 > tmp;
|
||||
|
@ -480,7 +482,7 @@ namespace llarp
|
|||
LogError("keyed hash failed");
|
||||
return false;
|
||||
}
|
||||
ShortHash expected(ptr);
|
||||
const ShortHash expected(ptr);
|
||||
if(expected != digest)
|
||||
{
|
||||
LogError("Message Integrity Failed: got ", digest, " from ", remoteAddr,
|
||||
|
|
Loading…
Reference in a new issue