Skip to content

perf(tickets): fetch Asana task context concurrently - #3293

Merged
IsmaelMartinez merged 2 commits into
The-PR-Agent:mainfrom
junnhwan:fix/parallel-asana-ticket-fetches
Sep 11, 2026
Merged

IsmaelMartinez merged 2 commits into
The-PR-Agent:mainfrom
junnhwan:fix/parallel-asana-ticket-fetches

Conversation

@junnhwan

Copy link
Copy Markdown
Contributor

Summary

  • fetch the existing bounded set of Asana ticket-context records concurrently
  • preserve input order and isolate ordinary per-ticket failures
  • cancel and drain sibling fetch tasks when the parent review is cancelled
  • add regression coverage for concurrency, ordering, partial failure, timeout, and cancellation cleanup

Problem and root cause

With ticket analysis enabled, /review resolves related tickets before prompt construction and the first model call. _fetch_asana_ticket_contents awaited up to three independent Asana HTTP reads one at a time, so pre-model latency grew with the sum of their response times.

The change keeps one authenticated aiohttp.ClientSession and the existing three-ticket cap, but starts the validated requests as a bounded batch. Results are consumed in original input order, so prompt context and downstream merge/publication behavior do not depend on completion order.

Benchmark

Offline fixed workload: three valid task URLs, 20 ms deterministic async I/O per task, two warmups, 30 measured batches, Python 3.12.14, Linux/aarch64.

Metric Baseline This change Change
wall p50 68.863 ms 22.030 ms 68.01% lower
wall p95 74.737 ms 25.522 ms 65.85% lower
mean wall 68.734 ms 22.424 ms 67.38% lower
batches/s from p50 14.52 45.39 212.59% higher
fetch calls / 30 batches 90 90 unchanged
peak traced memory p50 3,598 B 7,484 B +3,886 B

Formula: (baseline - optimized) / baseline * 100%.

This is an offline orchestration benchmark, not a claim about live Asana or end-to-end model latency.

Semantics preserved

  • same validated Asana endpoint and bearer token
  • same local session and total request timeout
  • same maximum of three attempted ticket URLs
  • same successful ticket payloads and input ordering
  • same ordinary partial-failure behavior
  • no changes to prompt/token construction, provider/model calls, retry/fallback, permissions, progress comments, or result publication
  • parent cancellation now explicitly cancels and drains all sibling tasks before propagation

Tests

  • pytest tests/unittest/test_ticket_compliance.py tests/unittest/test_ticket_pr_compliance_capabilities.py tests/unittest/test_fetching_sub_issues.py tests/unittest/test_retry_with_fallback_models.py tests/unittest/test_pr_reviewer_core.py tests/unittest/test_pr_description.py -q
  • pytest -q
  • ruff check .
  • pre-commit run --all-files
  • Docker test image built from the current uv.lock

Closes #3292

Signed-off-by: hwan <3373484735@qq.com>

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the #3292 write-up, the call chain in it made this quick to follow.

Close. The concurrency itself is well pinned: with the source reverted to main both new tests go red, and the three-ticket cap, warning text and partial-failure behaviour are unchanged.

The one gap is the behaviour you lead with in the description. Delete the whole except BaseException body and test_asana_ticket_batch_cancellation_cleans_up_in_flight_fetches still passes, because that test only distinguishes sequential from concurrent. The block does earn its place, gather leaves siblings running when a child raises BaseException, so a case for that would pin it.

The CodeQL alert on await batch is a false positive. I will dismiss it.

Signed-off-by: hwan <3373484735@qq.com>
@qodo-code-review

qodo-code-review Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@junnhwan

Copy link
Copy Markdown
Contributor Author

Thanks for catching that gap. I added test_asana_ticket_child_abort_cancels_and_drains_siblings in bada1710.

The new test starts all three fetches, makes one child raise a custom BaseException, keeps the two siblings blocked, and verifies that both siblings are cancelled and drained before the original exception is re-raised.

As a baseline-red check, I temporarily removed the except BaseException cleanup body; the test then failed with two sibling fetches still active. Restoring the implementation makes it pass.

I also reran the related suite (255 passed), the full suite (7515 passed, 33 skipped, 1 xfailed), Ruff, changed-file pre-commit hooks, and git diff --check.

Thanks as well for confirming that the CodeQL alert is a false positive.

Comment thread tests/unittest/test_ticket_compliance.py Dismissed

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean follow-through. I repeated your mutation check on a merge with today's main: with the except BaseException body removed, the child-abort test fails with two sibling fetches still active, and restoring the cleanup returns the file to 40 passing. The fresh CodeQL alert on await batch is the same false positive flagged on the earlier commit; I will dismiss it. Ready to merge, closing #3292.

@IsmaelMartinez
IsmaelMartinez merged commit ed2817a into The-PR-Agent:main Sep 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(tickets): fetch independent Asana task context concurrently

3 participants