Browse Source

memory poll for RouterProfile

cpu
orignal 1 year ago
parent
commit
c112276eea
  1. 1
      libi2pd/NetDb.cpp
  2. 2
      libi2pd/NetDb.hpp
  3. 3
      libi2pd/Profiling.cpp
  4. 3
      libi2pd/Profiling.h

1
libi2pd/NetDb.cpp

@ -175,6 +175,7 @@ namespace data @@ -175,6 +175,7 @@ namespace data
if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance) ||
ts + i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT < lastProfilesCleanup)
{
m_RouterProfilesPool.CleanUpMt ();
if (m_PersistProfiles) PersistProfiles ();
DeleteObsoleteProfiles ();
lastProfilesCleanup = ts;

2
libi2pd/NetDb.hpp

@ -128,6 +128,7 @@ namespace data @@ -128,6 +128,7 @@ namespace data
};
std::shared_ptr<Lease> NewLease (const Lease& lease) { return m_LeasesPool.AcquireSharedMt (lease); };
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) { return m_IdentitiesPool.AcquireSharedMt (buf, len); };
std::shared_ptr<RouterProfile> NewRouterProfile () { return m_RouterProfilesPool.AcquireSharedMt (); };
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
@ -185,6 +186,7 @@ namespace data @@ -185,6 +186,7 @@ namespace data
i2p::util::MemoryPoolMt<RouterInfo::Addresses> m_RouterInfoAddressVectorsPool;
i2p::util::MemoryPoolMt<Lease> m_LeasesPool;
i2p::util::MemoryPoolMt<IdentityEx> m_IdentitiesPool;
i2p::util::MemoryPoolMt<RouterProfile> m_RouterProfilesPool;
};
extern NetDb netdb;

3
libi2pd/Profiling.cpp

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "FS.h"
#include "Log.h"
#include "Timestamp.h"
#include "NetDb.hpp"
#include "Profiling.h"
namespace i2p
@ -237,7 +238,7 @@ namespace data @@ -237,7 +238,7 @@ namespace data
if (it != g_Profiles.end ())
return it->second;
}
auto profile = std::make_shared<RouterProfile> ();
auto profile = netdb.NewRouterProfile ();
profile->Load (identHash); // if possible
std::unique_lock<std::mutex> l(g_ProfilesMutex);
g_Profiles.emplace (identHash, profile);

3
libi2pd/Profiling.h

@ -31,7 +31,7 @@ namespace data @@ -31,7 +31,7 @@ namespace data
const char PEER_PROFILE_USAGE_CONNECTED[] = "connected";
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 36; // in hours (1.5 days)
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 6 * 3600; // in seconds (6 hours)
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 3 * 3600; // in seconds (3 hours)
const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3600; // in seconds (1 hour)
const int PEER_PROFILE_DECLINED_RECENTLY_INTERVAL = 150; // in seconds (2.5 minutes)
const int PEER_PROFILE_PERSIST_INTERVAL = 3300; // in seconds (55 minutes)
@ -43,7 +43,6 @@ namespace data @@ -43,7 +43,6 @@ namespace data
public:
RouterProfile ();
RouterProfile& operator= (const RouterProfile& ) = default;
void Save (const IdentHash& identHash);
void Load (const IdentHash& identHash);

Loading…
Cancel
Save