Skip to content

Commit 419eba0

Browse files
committed
cache - prefetch flow records before checking their expiration
1 parent 37de563 commit 419eba0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

storage/cache.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ int NHTFlowCache::put_pkt(Packet &pkt)
327327
return 0;
328328
}
329329

330+
prefetch_export_expired();
331+
330332
uint64_t hashval = XXH64(m_key, m_keylen, 0); /* Calculates hash value from key created before. */
331333

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

655+
void NHTFlowCache::prefetch_export_expired() const
656+
{
657+
for (decltype(m_timeout_idx) i = m_timeout_idx; i < m_timeout_idx + m_line_new_idx; i++) {
658+
__builtin_prefetch(m_flow_table[i], 0, 1);
659+
}
660+
}
653661
}

storage/cache.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class CacheOptParser : public OptionsParser
159159
}
160160
};
161161

162-
class FlowRecord
162+
class alignas(64) FlowRecord
163163
{
164164
uint64_t m_hash;
165165

@@ -257,6 +257,7 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin
257257
void update_flow_end_reason_stats(uint8_t reason);
258258
void update_flow_record_stats(uint64_t packets_count);
259259
telemetry::Content get_cache_telemetry();
260+
void prefetch_export_expired() const;
260261

261262
#ifdef FLOW_CACHE_STATS
262263
void print_report();

0 commit comments

Comments
 (0)