Skip to content

Commit 71b3fc9

Browse files
committed
++ cache
1 parent 51c717e commit 71b3fc9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

storage/cache.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ int NHTFlowCache::put_pkt(Packet& packet)
524524
const std::variant<FlowKeyv4, FlowKeyv6> reversed_key = *FlowKeyFactory::create_reversed_key(&packet.src_ip, &packet.dst_ip,
525525
packet.src_port, packet.dst_port, packet.ip_proto, static_cast<IP>(packet.ip_version));
526526

527-
auto [row, flow_identification] = find_flow_index(direct_key, reversed_key, packet.vlan_id);
527+
auto [row, flow_identification] =
528+
find_flow_index(direct_key, reversed_key, packet.vlan_id);
528529

529530
if (std::holds_alternative<size_t>(flow_identification)) {
530531
const size_t hash_value = std::get<size_t>(flow_identification);
@@ -537,9 +538,10 @@ int NHTFlowCache::put_pkt(Packet& packet)
537538
if (!std::holds_alternative<std::pair<size_t, bool>>(flow_identification)) {
538539
std::cout << std::endl;
539540
}
540-
const auto [flow_index, source_to_destination] = std::get<std::pair<size_t, bool>>(flow_identification);
541-
const size_t hash_value = m_flow_table[flow_index]->m_flow.flow_hash;
541+
const auto& [flow_index, source_to_destination] = std::get<std::pair<size_t, bool>>(flow_identification);
542+
542543
#ifdef WITH_CTT
544+
const size_t hash_value = m_flow_table[flow_index]->m_flow.flow_hash;
543545
const bool flow_is_waiting_for_export = !try_to_export_delayed_flow(packet, flow_index) && m_flow_table[flow_index]->is_waiting_for_export;
544546
#else
545547
constexpr bool flow_is_waiting_for_export = false;

storage/cacheRowSpan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CacheRowSpan {
6666
*/
6767
std::optional<size_t> find_empty() const noexcept;
6868

69-
FlowRecord*& operator[](const size_t index) const noexcept
69+
__attribute__((always_inline)) FlowRecord*& operator[](const size_t index) const noexcept
7070
{
7171
return m_begin[index];
7272
}

storage/flowRecord.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class alignas(64) FlowRecord
6666
{
6767
return hash == m_hash && m_flow.vlan_id == vlan_id;
6868
}
69+
6970
void create(const Packet &pkt, uint64_t pkt_hash);
7071
void update(const Packet &pkt);
7172
};

0 commit comments

Comments
 (0)