Skip to content

[perf] Batch rpyc calls in multimodal path -2 #973

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 4 commits into
base: main
Choose a base branch
from

Conversation

SangChengC
Copy link
Contributor

No description provided.

@SangChengC SangChengC changed the title Fix rpyc 0715 [perf] Batch rpyc calls in multimodal path -2 Jul 16, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @SangChengC, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on optimizing the multimodal cache system by introducing batch processing for cache operations and enabling necessary RPyC serialization. These changes aim to reduce RPC overhead and improve the efficiency of data handling within the system, while also simplifying the underlying cache manager's design.

Highlights

  • Performance Optimization: Batched Cache Operations: The cache manager's API has been refactored to support batch operations for allocating, releasing, and checking/setting item data and embeddings. This significantly reduces the number of individual RPyC calls, improving overall performance by minimizing RPC overhead.
  • RPyC Configuration Update: All RPyC connections to the cache server now explicitly include config={'allow_pickle': True}. This enables the serialization and deserialization of complex Python objects, which is essential for passing data like torch.Tensor or custom data structures over the RPC connection.
  • Cache Manager Architecture Simplification: The CacheManager interface and CacheManagerFactory abstraction have been removed. The InMemoryCache implementation is now directly used, simplifying the cache system's architecture and reducing indirection.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces batch rpyc calls in the multimodal path, aiming to enhance performance. However, it's crucial to address a logic error in the audio embedding cache, a race condition in the cache implementation, and an argument passing bug in the rpyc cache server.

Comment on lines 35 to 49
def exposed_set_items_data(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_data(ids=ids)

def exposed_get_item_data(self, id: int) -> bool:
id = obtain(id)
return self._impl.get_item_data(id=id)
def exposed_get_items_data(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_data(ids=ids)

def exposed_set_item_embed(self, id: int) -> None:
id = obtain(id)
return self._impl.set_item_embed(id=id)
def exposed_set_items_embed(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_embed(ids=ids)

def exposed_get_item_embed(self, id: int) -> bool:
id = obtain(id)
return self._impl.get_item_embed(id=id)
def exposed_get_items_embed(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_embed(ids=ids)

Choose a reason for hiding this comment

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

high

The calls to the underlying cache implementation (self._impl) are using keyword arguments (e.g., ids=ids), but the methods on InMemoryCache expect positional arguments. This will cause a TypeError at runtime. The arguments should be passed positionally.

Suggested change
def exposed_set_items_data(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_data(ids=ids)
def exposed_get_item_data(self, id: int) -> bool:
id = obtain(id)
return self._impl.get_item_data(id=id)
def exposed_get_items_data(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_data(ids=ids)
def exposed_set_item_embed(self, id: int) -> None:
id = obtain(id)
return self._impl.set_item_embed(id=id)
def exposed_set_items_embed(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_embed(ids=ids)
def exposed_get_item_embed(self, id: int) -> bool:
id = obtain(id)
return self._impl.get_item_embed(id=id)
def exposed_get_items_embed(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_embed(ids=ids)
def exposed_set_items_data(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_data(ids)
def exposed_get_items_data(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_data(ids)
def exposed_set_items_embed(self, ids: list[int]) -> None:
ids = obtain(ids)
return self._impl.set_items_embed(ids)
def exposed_get_items_embed(self, ids: list[int]) -> list[bool]:
ids = obtain(ids)
return self._impl.get_items_embed(ids)

@SangChengC SangChengC force-pushed the fix-rpyc-0715 branch 3 times, most recently from 3646451 to 0271d7e Compare July 17, 2025 07:02
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.

1 participant