Skip to content

Simplify TcpReassembly connection purge to use multimap.#2104

Open
Dimi1010 wants to merge 1 commit intoseladb:devfrom
Dimi1010:refactor/tcp-reassembly-purge-multimap
Open

Simplify TcpReassembly connection purge to use multimap.#2104
Dimi1010 wants to merge 1 commit intoseladb:devfrom
Dimi1010:refactor/tcp-reassembly-purge-multimap

Conversation

@Dimi1010
Copy link
Copy Markdown
Collaborator

The change removes the need to create a list for situations where only 1 connection will be purged at time T.
Instead the additional flow keys at time T will be directly inserted into the multimap as additional nodes.

The change also simplifies the purge code down to a single loop over the range of nodes [beginIt, upperBound(T)).
Since multimap<K, V> is an ordered container, the connections are purged in the order: oldest expire time -> oldest insertion.

…p<K, list<V>>.

The change removes the need to create a list for situations where only 1 connection will be purged at time T.
Instead the additional flow keys at time T will be directly inserted into the multimap as additional nodes.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.92%. Comparing base (718ae23) to head (ac60473).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2104      +/-   ##
==========================================
- Coverage   83.93%   83.92%   -0.01%     
==========================================
  Files         316      316              
  Lines       57024    57010      -14     
  Branches    11790    12082     +292     
==========================================
- Hits        47863    47848      -15     
+ Misses       8006     7967      -39     
- Partials     1155     1195      +40     
Flag Coverage Δ
alpine320 76.63% <100.00%> (+<0.01%) ⬆️
fedora42 76.20% <100.00%> (-0.01%) ⬇️
macos-14 82.03% <100.00%> (-0.01%) ⬇️
macos-15 82.02% <100.00%> (-0.01%) ⬇️
mingw32 70.73% <100.00%> (-0.02%) ⬇️
mingw64 70.70% <100.00%> (+0.07%) ⬆️
npcap ?
rhel94 76.01% <100.00%> (-0.03%) ⬇️
ubuntu2004 59.77% <100.00%> (-0.01%) ⬇️
ubuntu2004-zstd 59.84% <100.00%> (-0.01%) ⬇️
ubuntu2204 76.02% <100.00%> (+<0.01%) ⬆️
ubuntu2204-icpx 59.07% <100.00%> (-0.04%) ⬇️
ubuntu2404 76.32% <100.00%> (-0.01%) ⬇️
ubuntu2404-arm64 76.32% <100.00%> (-0.03%) ⬇️
unittest 83.92% <100.00%> (-0.01%) ⬇️
windows-2022 85.55% <100.00%> (+0.08%) ⬆️
windows-2025 85.60% <100.00%> (+0.11%) ⬆️
winpcap 85.60% <100.00%> (-0.09%) ⬇️
xdp 52.71% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dimi1010 Dimi1010 marked this pull request as ready for review April 13, 2026 09:23
@Dimi1010 Dimi1010 requested a review from seladb as a code owner April 13, 2026 09:23

using ConnectionList = std::unordered_map<uint32_t, TcpReassemblyData>;
using CleanupList = std::map<time_t, std::list<uint32_t>>;
using CleanupList = std::multimap<time_t, uint32_t>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename it to CleanupMultiMap. The original naming is misleading.

// removed from storage.

auto expireTime = time(nullptr) + m_ClosedConnectionDelay;
m_CleanupList.insert(std::make_pair(expireTime, flowKey));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if emplace is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants