table: improve logging in DeadNonceList
Refs: #5165 Change-Id: I97f9e28af90d857b33808d385eb077380cafe00a
This commit is contained in:
1 parent
67ad70fbd5
commit
e08cc4cd7e
4 files changed
+29
-22
No files matched your search
@@ -566,13 +566,13 @@ Forwarder::setExpiryTimer(const shared_ptr<pit::Entry>& pitEntry, time::millisec
|
||||
}
|
||||
|
||||
void
|
||||
Forwarder::insertDeadNonceList(pit::Entry& pitEntry, Face* upstream)
|
||||
Forwarder::insertDeadNonceList(pit::Entry& pitEntry, const Face* upstream)
|
||||
{
|
||||
// need Dead Nonce List insert?
|
||||
bool needDnl = true;
|
||||
if (pitEntry.isSatisfied) {
|
||||
BOOST_ASSERT(pitEntry.dataFreshnessPeriod >= 0_ms);
|
||||
needDnl = static_cast<bool>(pitEntry.getInterest().getMustBeFresh()) &&
|
||||
needDnl = pitEntry.getInterest().getMustBeFresh() &&
|
||||
pitEntry.dataFreshnessPeriod < m_deadNonceList.getLifetime();
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // pipelines
|
||||
NFD_VIRTUAL_WITH_TESTS void
|
||||
onNewNextHop(const Name& prefix, const fib::NextHop& nextHop);
|
||||
|
||||
NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE:
|
||||
private:
|
||||
/** \brief set a new expiry timer (now + \p duration) on a PIT entry
|
||||
*/
|
||||
void
|
||||
@@ -234,8 +234,8 @@ NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE:
|
||||
* \param upstream if null, insert Nonces from all out-records;
|
||||
* if not null, insert Nonce only on the out-records of this face
|
||||
*/
|
||||
NFD_VIRTUAL_WITH_TESTS void
|
||||
insertDeadNonceList(pit::Entry& pitEntry, Face* upstream);
|
||||
void
|
||||
insertDeadNonceList(pit::Entry& pitEntry, const Face* upstream);
|
||||
|
||||
private:
|
||||
ForwarderCounters m_counters;
|
||||
|
||||
@@ -45,8 +45,6 @@ const size_t DeadNonceList::EVICT_LIMIT;
|
||||
|
||||
DeadNonceList::DeadNonceList(time::nanoseconds lifetime)
|
||||
: m_lifetime(lifetime)
|
||||
, m_queue(m_index.get<0>())
|
||||
, m_ht(m_index.get<1>())
|
||||
, m_capacity(INITIAL_CAPACITY)
|
||||
, m_markInterval(m_lifetime / EXPECTED_MARK_COUNT)
|
||||
, m_adjustCapacityInterval(m_lifetime)
|
||||
@@ -91,10 +89,13 @@ void
|
||||
DeadNonceList::add(const Name& name, Interest::Nonce nonce)
|
||||
{
|
||||
Entry entry = DeadNonceList::makeEntry(name, nonce);
|
||||
|
||||
const auto iter = m_ht.find(entry);
|
||||
if (iter != m_ht.end()) {
|
||||
m_queue.relocate(m_queue.end(), m_index.project<0>(iter));
|
||||
bool isDuplicate = iter != m_ht.end();
|
||||
|
||||
NFD_LOG_TRACE("adding " << (isDuplicate ? "duplicate " : "") << name << " nonce=" << nonce);
|
||||
|
||||
if (isDuplicate) {
|
||||
m_queue.relocate(m_queue.end(), m_index.project<Queue>(iter));
|
||||
}
|
||||
else {
|
||||
m_queue.push_back(entry);
|
||||
@@ -132,16 +133,19 @@ DeadNonceList::mark()
|
||||
void
|
||||
DeadNonceList::adjustCapacity()
|
||||
{
|
||||
auto oldCapacity = m_capacity;
|
||||
auto equalRange = m_actualMarkCounts.equal_range(EXPECTED_MARK_COUNT);
|
||||
if (equalRange.second == m_actualMarkCounts.begin()) {
|
||||
// all counts are above expected count, adjust down
|
||||
m_capacity = std::max(MIN_CAPACITY, static_cast<size_t>(m_capacity * CAPACITY_DOWN));
|
||||
NFD_LOG_TRACE("adjustCapacity DOWN capacity=" << m_capacity);
|
||||
}
|
||||
else if (equalRange.first == m_actualMarkCounts.end()) {
|
||||
// all counts are below expected count, adjust up
|
||||
m_capacity = std::min(MAX_CAPACITY, static_cast<size_t>(m_capacity * CAPACITY_UP));
|
||||
NFD_LOG_TRACE("adjustCapacity UP capacity=" << m_capacity);
|
||||
}
|
||||
|
||||
if (m_capacity != oldCapacity) {
|
||||
NFD_LOG_TRACE("adjusting capacity " << oldCapacity << " -> " << m_capacity);
|
||||
}
|
||||
|
||||
m_actualMarkCounts.clear();
|
||||
@@ -157,10 +161,12 @@ DeadNonceList::evictEntries()
|
||||
return;
|
||||
|
||||
auto nEvict = std::min(m_queue.size() - m_capacity, EVICT_LIMIT);
|
||||
for (; nEvict > 0; --nEvict) {
|
||||
m_queue.erase(m_queue.begin());
|
||||
for (size_t i = 0; i < nEvict; i++) {
|
||||
m_queue.pop_front();
|
||||
}
|
||||
BOOST_ASSERT(m_queue.size() >= m_capacity);
|
||||
|
||||
NFD_LOG_TRACE("evicted=" << nEvict << " size=" << size() << " capacity=" << m_capacity);
|
||||
}
|
||||
|
||||
} // namespace nfd
|
||||
@@ -131,19 +131,20 @@ public:
|
||||
private:
|
||||
const time::nanoseconds m_lifetime;
|
||||
|
||||
using Index = boost::multi_index_container<
|
||||
struct Queue {};
|
||||
struct Hashtable {};
|
||||
using Container = boost::multi_index_container<
|
||||
Entry,
|
||||
boost::multi_index::indexed_by<
|
||||
boost::multi_index::sequenced<>,
|
||||
boost::multi_index::hashed_non_unique<boost::multi_index::identity<Entry>>
|
||||
boost::multi_index::sequenced<boost::multi_index::tag<Queue>>,
|
||||
boost::multi_index::hashed_non_unique<boost::multi_index::tag<Hashtable>,
|
||||
boost::multi_index::identity<Entry>>
|
||||
>
|
||||
>;
|
||||
using Queue = Index::nth_index<0>::type;
|
||||
using Hashtable = Index::nth_index<1>::type;
|
||||
|
||||
Index m_index;
|
||||
Queue& m_queue;
|
||||
Hashtable& m_ht;
|
||||
Container m_index;
|
||||
Container::index<Queue>::type& m_queue = m_index.get<Queue>();
|
||||
Container::index<Hashtable>::type& m_ht = m_index.get<Hashtable>();
|
||||
|
||||
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
|
||||
Reference in new issue
Block a user