Skip to content

[PERF] Don't use hmac encryption for loopback interfaces #6241

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vadiklyutiy
Copy link
Contributor

@vadiklyutiy vadiklyutiy commented Jul 22, 2025

Description

In class ZeroMqQueue disable encryption for loopback interfaces.

The Reason
For Qwen-2.5-3B-VL main process (that get requests, pre-process images, send request to worker) is bottleneck. Images preprocessing and sending takes more time than inference.

send is around 35% from all time
image

inside send we spend around half to sign image with hmac.

I think we can avoid encryption for loopback interfaces

Performance

Tested Qwen-2.5-3B-VL model. H100. Images 512x512
Before image processing took 23ms per image.
After 17ms

image

Summary by CodeRabbit

  • New Features
    • Automatically disables encryption for local or loopback IPC connections to improve performance.
  • Bug Fixes
    • Ensures correct detection of local addresses to apply appropriate security settings.

@vadiklyutiy vadiklyutiy requested a review from a team as a code owner July 22, 2025 01:55
@vadiklyutiy vadiklyutiy requested a review from syuoni July 22, 2025 01:55
Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

A new utility function was introduced to detect loopback or local IPC addresses, including various protocols and address patterns. The constructor logic for ZeroMqQueue was updated to use this function, disabling HMAC encryption automatically for local or loopback connections.

Changes

File(s) Change Summary
tensorrt_llm/executor/ipc.py Added is_address_loopback function; updated ZeroMqQueue constructor to use it and adjust HMAC encryption logic accordingly.

Estimated code review effort

2 (~12 minutes)

Poem

A clever new check for the loopback’s embrace,
Now keeps local traffic in a safer place.
HMAC takes a rest when localhost is near,
Encryption skipped, intentions clear.
With each hop and hop, our code grows bright—
Hooray for the loopback, and changes done right! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2d8787 and 7ec1b95.

📒 Files selected for processing (1)
  • tensorrt_llm/executor/ipc.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/executor/ipc.py
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
tensorrt_llm/executor/ipc.py (3)

20-20: Fix grammatical error in function name.

The function name is_address_is_loopback contains a redundant "is". Consider renaming to is_address_loopback for better readability.

-def is_address_is_loopback(address: str) -> bool:
+def is_address_loopback(address: str) -> bool:

Don't forget to update the function call on line 69 as well.


21-36: Consider edge case handling and validation for robustness.

The current implementation correctly identifies the main loopback patterns for the performance optimization goal. However, consider these potential improvements for robustness:

  1. The IPv4 loopback check tcp://127.* might match malformed addresses like tcp://127.abc
  2. Missing validation for malformed address formats

Here's a more robust implementation if you want to handle edge cases:

def is_address_loopback(address: str) -> bool:
    """Check if the address represents a local/loopback connection."""
    # IPC and inproc are always local
    if address.startswith(("ipc://", "inproc://")):
        return True

    # Check TCP loopback addresses
    if address.startswith("tcp://"):
+        # Extract the host part
+        try:
+            host_part = address[6:].split(':')[0]  # Remove tcp:// and port
+            # IPv4 loopback patterns
+            if host_part.startswith("127.") or host_part == "localhost":
+                return True
+            # IPv6 loopback
+            if host_part == "[::1]":
+                return True
+        except (IndexError, ValueError):
+            # Malformed address, assume not loopback for safety
+            return False
-        # IPv4 loopback patterns
-        if (address.startswith("tcp://127.")
-                or address.startswith("tcp://localhost")):
-            return True
-        # IPv6 loopback
-        if address.startswith("tcp://[::1]"):
-            return True

    return False

However, the current implementation is sufficient for the intended performance optimization use case.


69-70: Update function call and consider logging the encryption override.

Two considerations for this change:

  1. Function name: Update the function call to match the corrected name.
  2. Transparency: Consider logging when encryption is automatically disabled to make the behavior visible to users.
-        if is_address_is_loopback(self.address_endpoint):
+        if is_address_loopback(self.address_endpoint):
             use_hmac_encryption = False
+            if name:  # Only log if we have a name to identify the queue
+                logger.debug(f"Disabled HMAC encryption for loopback address in queue '{name}'")

This change overrides the user's use_hmac_encryption setting for loopback addresses, which is appropriate for the performance optimization goal. The security trade-off is acceptable since loopback connections are inherently local and trusted.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee45e0c and e2d8787.

📒 Files selected for processing (1)
  • tensorrt_llm/executor/ipc.py (2 hunks)
🔇 Additional comments (1)
tensorrt_llm/executor/ipc.py (1)

69-70: Performance optimization approach looks good.

This change effectively addresses the performance bottleneck described in the PR objectives. Disabling HMAC encryption for loopback connections is a sound optimization that should deliver the observed performance improvements (23ms to 17ms per image) without compromising security for local communications.

Signed-off-by: Vadim Gimpelson <[email protected]>
@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community want to contribute PRs initiated from Community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants