Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mirroring for high stress #2561

Merged
merged 17 commits into from
Jul 2, 2024

Conversation

Razz4780
Copy link
Contributor

@Razz4780 Razz4780 commented Jul 1, 2024

Closes #2529

  1. TcpConnectionSniffer uses broadcast channels (capacity - 512 TCP packets) to send incoming data in a non-blocking way.
  2. TcpSnifferApi notifies the client about closed connection (and sends an error log) when it's broadcast::Receiver is lagging.
  3. TcpConnectionSniffer notifies TcpSnifferApis about new connections via mpsc channels (capacity - 128 new sniffed connections). When a new connection is sniffed, the sniffer attempts to notify each client without blocking. If the client already has 128 queued new connections, client is not notified. There's some space for improvement here - instead of dropping new connection, we could be dropping the oldest one in the queue. However, mpsc::Sender's api does not allow for it and we would need to implement some async circular FIFO
  4. BPF filter used by the raw socket is now updated only when needed - PortSubscribe/PortUnsubscribe from a user actually changed the set of subscribed ports
  5. Also some minor performance optimizations like using hash_map::Entry instead of get() -> remove()

Copy link
Member

@meowjesty meowjesty left a comment

Choose a reason for hiding this comment

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

Getting rid of the nits and requests for docs first.

mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Show resolved Hide resolved
mirrord/agent/src/sniffer/messages.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer/messages.rs Show resolved Hide resolved
Copy link
Member

@meowjesty meowjesty left a comment

Choose a reason for hiding this comment

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

Just some more minor stuff, but it's worthy of approval.

Thanks for the docs, I'm happy now.

mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer.rs Outdated Show resolved Hide resolved
mirrord/agent/src/sniffer/messages.rs Outdated Show resolved Hide resolved
mirrord/agent/src/util.rs Outdated Show resolved Hide resolved
mirrord/agent/src/util.rs Outdated Show resolved Hide resolved
@Razz4780
Copy link
Contributor Author

Razz4780 commented Jul 2, 2024

Something is not working and I don't yet know what ;/
Added some unit tests to TcpConnectionSniffer, but they all pass

@Razz4780 Razz4780 requested a review from meowjesty July 2, 2024 14:56
Copy link
Member

@meowjesty meowjesty left a comment

Choose a reason for hiding this comment

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

👍

@Razz4780 Razz4780 added this pull request to the merge queue Jul 2, 2024
Merged via the queue into metalbear-co:main with commit dbe58ed Jul 2, 2024
16 checks passed
@Razz4780 Razz4780 deleted the high-stress-mirroring branch July 2, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Research sessions failing under high stress mirroring
2 participants