Skip to content

Commit

Permalink
cache - prefetch flow records before checking their expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSableCZ committed Sep 26, 2024
1 parent 37de563 commit 419eba0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions storage/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ int NHTFlowCache::put_pkt(Packet &pkt)
return 0;
}

prefetch_export_expired();

uint64_t hashval = XXH64(m_key, m_keylen, 0); /* Calculates hash value from key created before. */

FlowRecord *flow; /* Pointer to flow we will be working with. */
Expand Down Expand Up @@ -650,4 +652,10 @@ telemetry::Content NHTFlowCache::get_cache_telemetry()
return dict;
}

void NHTFlowCache::prefetch_export_expired() const
{
for (decltype(m_timeout_idx) i = m_timeout_idx; i < m_timeout_idx + m_line_new_idx; i++) {
__builtin_prefetch(m_flow_table[i], 0, 1);
}
}
}
3 changes: 2 additions & 1 deletion storage/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class CacheOptParser : public OptionsParser
}
};

class FlowRecord
class alignas(64) FlowRecord
{
uint64_t m_hash;

Expand Down Expand Up @@ -257,6 +257,7 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin
void update_flow_end_reason_stats(uint8_t reason);
void update_flow_record_stats(uint64_t packets_count);
telemetry::Content get_cache_telemetry();
void prefetch_export_expired() const;

#ifdef FLOW_CACHE_STATS
void print_report();
Expand Down

0 comments on commit 419eba0

Please sign in to comment.