Skip to content

Fix: Parallelize preprocessing to reduce unnecessary latency - #111

Closed
bleedblack1 wants to merge 1 commit into
reactome:mainfrom
bleedblack1:fix/sequential-preprocessing-latency
Closed

Fix: Parallelize preprocessing to reduce unnecessary latency#111
bleedblack1 wants to merge 1 commit into
reactome:mainfrom
bleedblack1:fix/sequential-preprocessing-latency

Conversation

@bleedblack1

Copy link
Copy Markdown

Problem

Preprocessing steps were executed sequentially, causing unnecessary latency.

Solution

Replaced sequential execution with parallel processing using asyncio.gather.

Impact

Reduces preprocessing latency by executing independent steps concurrently.

Related Issue

Closes #110

adamjohnwright added a commit that referenced this pull request Sep 4, 2026
preprocess made three LLM calls back to back. The safety check needs the
rephrased text so it must follow the rephrase, but language detection reads the
raw user input and does not -- so those two now run concurrently, saving one
round trip on every message, on the path every profile shares.

Idea from @bleedblack1 in #111. That patch parallelised the same two calls; this
is the same change written against current main, since the PR predates 34
commits and its diff no longer applies.

Two tests, both checked against the sequential version to confirm they fail on
it: one asserting the two calls actually overlap in wall-clock time, one
asserting the rephrase still completes before the safety check starts, which is
the ordering constraint that must not be lost.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@adamjohnwright

Copy link
Copy Markdown
Contributor

Thank you — this was a real bug and your report is what surfaced it.

Fixed on main in #173. The change is rewritten against current main rather than merged directly: this PR predates 34 commits, including a repo-wide lint/format pass, so the diff no longer applies. Your fix and your name are recorded in the commit message.

Closing as resolved rather than stale.

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.

Sequential Preprocessing Creates Unnecessary Latency

2 participants