Skip to content

postprocess: run function transformations asynchronously with bounded jobs - #1997

Open
thedataking wants to merge 3 commits into
perl/postprocess-cleanupfrom
perl/postprocess-async-jobs
Open

postprocess: run function transformations asynchronously with bounded jobs#1997
thedataking wants to merge 3 commits into
perl/postprocess-cleanupfrom
perl/postprocess-async-jobs

Conversation

@thedataking

Copy link
Copy Markdown
Contributor

Stacked on #1996.

Process up to four functions concurrently per Rust file using native async OpenAI/OpenRouter and Gemini clients. Set -j N / --jobs N to control the limit; -j 1 runs serially.

Each function keeps its trim/retry sequence, and files and transform passes remain sequential. Responses are applied in source order through the existing batch validator. Abort cancels pending work, and cancellation during validation restores the current batch.

Prompts and cache keys stay unchanged, so existing CI caches and serial/parallel reruns share responses. No new dependencies.

Validation: 79 tests passed; four tests requiring a local c2rust binary skipped. Ruff format, Ruff lint, and ty passed. Tests cover concurrency bounds, ordered writes, abort/rollback, client cleanup, and frozen cache replay. Live model testing is left to you.

Use the native async OpenAI and Gemini clients and await trimming, response validation/retries, and comment transfer without changing prompts or cache keys. Keep file processing serial in this commit.

Run the CLI in one event loop and close model transports before it exits, including on failure. Adapt existing tests with asyncio.run and exercise SDK request forwarding with fake clients; no live model calls are needed.
asyncio.run handles Ctrl-C by cancelling the main task. A synchronous merge or cargo check can return with that cancellation still pending, bypassing the existing rollback boundary.

Await cancellation checkpoints inside the transaction before checking and before accepting the batch. Keep bisection sequential and cover cancellation during both merge and check, including restoration of the original file.
Use a small pool of async workers to overlap independent functions within each Rust file. Add -j/--jobs with a default of four and require a positive limit; -j 1 preserves serial processing.

Keep trimming and retries within each worker, and process files and transform passes sequentially. Collect responses before merging, apply candidates in source order, and cancel and await outstanding workers on abort. Existing prompts and cache entries remain reusable without locks or new dependencies.

Test the concurrency bound, ordered writes, failure handling, cancellation, serial replay of a parallel-populated frozen cache, CLI validation, and client cleanup. All 79 local tests passed; four c2rust-dependent tests skipped. Ruff and ty checks passed without live model calls.
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