Skip to content

fix: stream records lazily in write_records and _execute_chunk_v2#800

Open
shivamsharma2106 wants to merge 2 commits into
developfrom
fix/generating-command-oom-list-materialization
Open

fix: stream records lazily in write_records and _execute_chunk_v2#800
shivamsharma2106 wants to merge 2 commits into
developfrom
fix/generating-command-oom-list-materialization

Conversation

@shivamsharma2106

@shivamsharma2106 shivamsharma2106 commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Problem:
_execute_chunk_v2 was accumulating all records into a list before writing them, causing OOM (out-of-memory) errors when generating commands produced large result sets. Similarly, write_records was materializing the full iterator into a list upfront.

Fix:

  • In _execute_chunk_v2: write each record immediately as it is generated instead of buffering all records first.
  • In write_records: return early if records is NotImplemented instead of materializing into an empty list.

This makes both methods stream records lazily, avoiding unnecessary memory allocation.

@Ickerday Ickerday requested review from Ickerday and mateusz834 June 8, 2026 15:59
@Ickerday Ickerday linked an issue Jun 8, 2026 that may be closed by this pull request
@Ickerday Ickerday force-pushed the fix/generating-command-oom-list-materialization branch from ae7f1d4 to c64a592 Compare June 9, 2026 13:17
@Ickerday

Ickerday commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Whoops, my bad. Reverting

@Ickerday Ickerday force-pushed the fix/generating-command-oom-list-materialization branch from c64a592 to ae7f1d4 Compare June 9, 2026 13:29
@Ickerday

Ickerday commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

@shivamsharma2106 could I ask you to have a look at #804 and try it out? It's a dirty workaround, but getting rid of list() here breaks current functionality.

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.

Custom command have high CPU load / RAM usage

2 participants