-
Notifications
You must be signed in to change notification settings - Fork 63
perf: reduce system bubble time #154
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ChenZiHong-Gavin, 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 focuses on optimizing the performance and robustness of the graph generation pipeline, particularly concerning knowledge graph building and quiz generation. Key changes include refactoring the quiz generation process to leverage batch processing, enhancing the output of knowledge graph building functions to return explicit nodes and edges, and improving error handling in graph partitioning. These modifications aim to reduce "system bubble time" by streamlining data flow and making operations more resilient. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this 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 refactors the data processing pipeline to reduce system bubble time, primarily by changing the quiz operator from an aggregate type to map_batch. This allows for better pipelining and parallelism with the build_kg step. The changes in build_kg and related functions to pass nodes and edges forward are well-implemented and support this new architecture.
However, I've identified a few potential issues in the new quiz_service.py implementation that should be addressed to ensure the new implementation is both efficient and correct:
- A caching mechanism that prevented re-generation of existing quizzes has been removed, which could lead to redundant work and increased costs.
- The logic for processing nodes and edges from the input batch appears to handle only the first data entry for each item, potentially ignoring other valid data and leading to incomplete quiz generation.
| for node_id, node_data in nodes.items(): | ||
| node_data = node_data[0] | ||
| desc = node_data["description"] | ||
| items.append((node_id, desc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nodes dictionary maps a node ID to a list of data dictionaries. This code only processes the first element of that list (node_data[0]), potentially ignoring other data associated with the same node. This could result in incomplete processing if a node is associated with multiple descriptions (e.g., from different source chunks). Consider iterating through the entire list of data dictionaries to process all available descriptions.
| for node_id, node_data in nodes.items(): | |
| node_data = node_data[0] | |
| desc = node_data["description"] | |
| items.append((node_id, desc)) | |
| for node_id, node_data_list in nodes.items(): | |
| for node_data in node_data_list: | |
| desc = node_data["description"] | |
| items.append((node_id, desc)) |
| for edge_key, edge_data in edges.items(): | ||
| edge_data = edge_data[0] | ||
| desc = edge_data["description"] | ||
| items.append((edge_key, desc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the loop for nodes, this loop for edges only processes the first data dictionary (edge_data[0]) for each edge. If an edge can have multiple associated data dictionaries, this will lead to data loss. To ensure all descriptions are processed, you should iterate through the list of data dictionaries for each edge.
| for edge_key, edge_data in edges.items(): | |
| edge_data = edge_data[0] | |
| desc = edge_data["description"] | |
| items.append((edge_key, desc)) | |
| for edge_key, edge_data_list in edges.items(): | |
| for edge_data in edge_data_list: | |
| desc = edge_data["description"] | |
| items.append((edge_key, desc)) |
| _quiz_id = compute_dict_hash({"index": index, "description": desc}) | ||
| if self.quiz_storage.get_by_id(_quiz_id): | ||
| return None | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for an existing quiz in quiz_storage has been removed. This will cause quizzes to be regenerated every time _process_single_quiz is called for the same item, even if a quiz already exists. This could lead to redundant processing and increased costs. Consider adding the check back:
if self.quiz_storage.get_by_id(_quiz_id):
return None
Before:

After:
