-
Notifications
You must be signed in to change notification settings - Fork 55
perf(diff): batch node field summary retrieval over paged queries #10106
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: release-1.11
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -588,11 +588,32 @@ async def get_affected_node_uuids( | |
| async def get_node_field_summaries( | ||
| self, diff_branch_name: str, tracking_id: TrackingId | None = None, diff_id: str | None = None | ||
| ) -> list[NodeDiffFieldSummary]: | ||
| query = await EnrichedDiffNodeFieldSummaryQuery.init( | ||
| db=self.db, diff_branch_name=diff_branch_name, tracking_id=tracking_id, diff_id=diff_id | ||
| ) | ||
| await query.execute(db=self.db) | ||
| return await query.get_field_summaries() | ||
| node_limit = config.SETTINGS.database.query_size_limit | ||
| node_offset = 0 | ||
| summaries_by_kind: dict[str, NodeDiffFieldSummary] = {} | ||
| while True: | ||
| query = await EnrichedDiffNodeFieldSummaryQuery.init( | ||
| db=self.db, | ||
| diff_branch_name=diff_branch_name, | ||
| tracking_id=tracking_id, | ||
| diff_id=diff_id, | ||
| node_offset=node_offset, | ||
| node_limit=node_limit, | ||
| ) | ||
| await query.execute(db=self.db) | ||
| num_nodes = 0 | ||
| for node_summary in query.get_node_field_rows(): | ||
| num_nodes += 1 | ||
| if not node_summary.attribute_node_uuids and not node_summary.relationship_node_uuids: | ||
| continue | ||
| kind_summary = summaries_by_kind.setdefault( | ||
| node_summary.kind, NodeDiffFieldSummary(kind=node_summary.kind) | ||
| ) | ||
| kind_summary.merge(node_summary) | ||
| if num_nodes < node_limit: | ||
| break | ||
| node_offset += node_limit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Very large diffs can still cause progressively larger query work and heap use: offset pagination makes the last Prompt for AI agents |
||
| return list(summaries_by_kind.values()) | ||
|
|
||
| async def mark_tracking_ids_merged(self, tracking_ids: list[TrackingId]) -> None: | ||
| query = await EnrichedDiffMergedTrackingIdQuery.init(db=self.db, tracking_ids=tracking_ids) | ||
|
|
||
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.
P2: Large diffs can still consume unbounded query work/memory as offsets grow: the final page must order nearly every changed node before
LIMITapplies. Use keyset pagination (last(uuid, elementId)cursor) so each query seeks after the previous node and limits immediately.Prompt for AI agents