more aggressive path building. (#1423)

* more aggressive path building.

* do more than one in parallel path builds at a time

* correct last commit's logic

* rename numPaths -> numDesiredPaths to clarify intent

* revert string change as it will break a lot

* don't prematurly short circuit on snode builds

Co-authored-by: Thomas Winget <tewinget@gmail.com>
pull/1433/head
Jeff 4 years ago committed by GitHub
parent e731eab4b6
commit 4c7d52ac20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,7 +58,7 @@ namespace llarp
{
if (BuildCooldownHit(now))
return false;
const size_t expect = (1 + (numPaths / 2));
const size_t expect = (1 + (numDesiredPaths / 2));
// check 30 seconds into the future and see if we need more paths
const llarp_time_t future = now + 30s + buildIntervalLimit;
return NumPathsExistingAt(future) < expect;
@ -250,7 +250,7 @@ namespace llarp
bool
BaseSession::IsReady() const
{
const size_t expect = (1 + (numPaths / 2));
const size_t expect = (1 + (numDesiredPaths / 2));
return AvailablePaths(llarp::path::ePathRoleExit) >= expect;
}
@ -265,9 +265,9 @@ namespace llarp
{
if (BuildCooldownHit(now))
return false;
if (!IsReady())
return NumInStatus(path::ePathBuilding) < numPaths;
return path::Builder::UrgentBuild(now);
if (IsReady() and NumInStatus(path::ePathBuilding) < numDesiredPaths)
return path::Builder::UrgentBuild(now);
return false;
}
bool

@ -191,7 +191,7 @@ namespace llarp
{
util::StatusObject obj{{"buildStats", m_BuildStats.ExtractStatus()},
{"numHops", uint64_t(numHops)},
{"numPaths", uint64_t(numPaths)}};
{"numPaths", uint64_t(numDesiredPaths)}};
std::transform(
m_Paths.begin(),
m_Paths.end(),

@ -44,7 +44,7 @@ namespace llarp
llarp_time_t buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
/// construct
Builder(AbstractRouter* p_router, size_t numPaths, size_t numHops);
Builder(AbstractRouter* p_router, size_t numDesiredPaths, size_t numHops);
virtual ~Builder() = default;

@ -11,7 +11,7 @@ namespace llarp
{
namespace path
{
PathSet::PathSet(size_t num) : numPaths(num)
PathSet::PathSet(size_t num) : numDesiredPaths(num)
{}
bool
@ -19,10 +19,10 @@ namespace llarp
{
(void)now;
const auto building = NumInStatus(ePathBuilding);
if (building >= numPaths)
if (building >= numDesiredPaths)
return false;
const auto established = NumInStatus(ePathEstablished);
return established < numPaths;
return established < numDesiredPaths;
}
bool

@ -97,8 +97,8 @@ namespace llarp
/// maximum number of paths a path set can maintain
static constexpr size_t max_paths = 32;
/// construct
/// @params numPaths the number of paths to maintain
PathSet(size_t numPaths);
/// @params numDesiredPaths the number of paths to maintain
PathSet(size_t numDesiredPaths);
/// get a shared_ptr of ourself
virtual PathSet_ptr
@ -296,7 +296,7 @@ namespace llarp
void
DownstreamFlush(AbstractRouter* r);
size_t numPaths;
size_t numDesiredPaths;
protected:
BuildStats m_BuildStats;

@ -52,7 +52,7 @@ namespace llarp
Endpoint::Configure(const NetworkConfig& conf, [[maybe_unused]] const DnsConfig& dnsConf)
{
if (conf.m_Paths.has_value())
numPaths = *conf.m_Paths;
numDesiredPaths = *conf.m_Paths;
if (conf.m_Hops.has_value())
numHops = *conf.m_Hops;
@ -1231,7 +1231,7 @@ namespace llarp
return HandleInboundPacket(tag, pkt.ConstBuffer(), eProtocolTrafficV4, 0);
},
Router(),
numPaths,
numDesiredPaths,
numHops,
false,
ShouldBundleRC());
@ -1466,13 +1466,8 @@ namespace llarp
bool
Endpoint::ShouldBuildMore(llarp_time_t now) const
{
if (path::Builder::BuildCooldownHit(now))
if (not path::Builder::ShouldBuildMore(now))
return false;
size_t numBuilding = NumInStatus(path::ePathBuilding);
if (numBuilding > 0)
return false;
return ((now - lastBuild) > path::intro_path_spread)
|| NumInStatus(path::ePathEstablished) < path::min_intro_paths;
}

@ -359,11 +359,9 @@ namespace llarp
bool
OutboundContext::ShouldBuildMore(llarp_time_t now) const
{
if (markedBad || path::Builder::BuildCooldownHit(now))
if (markedBad || not path::Builder::ShouldBuildMore(now))
return false;
const bool canBuild =
NumInStatus(path::ePathBuilding) == 0 and path::Builder::ShouldBuildMore(now);
if (not canBuild)
if (NumInStatus(path::ePathBuilding) >= numDesiredPaths)
return false;
llarp_time_t t = 0s;
ForEachPath([&t](path::Path_ptr path) {

Loading…
Cancel
Save