Skip to content

perf(artifact-delivery): build a Resolution in its own request - #508

Merged
harlan-zw merged 3 commits into
perf/run-waitfrom
perf/build-in-request
Oct 7, 2026
Merged

harlan-zw merged 3 commits into
perf/run-waitfrom
perf/build-in-request

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #497.

🔗 Linked issue

None. Launch prep for skilld run latency, approved by Harlan.

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

A cold build waited for the queue, then ran far from its database. In 20 timed production runs on 2026-10-07, the queue delivered a build 1.2 s after the request at the median and 3.4 s at worst. Its consumer ran in US colos (SJC, LAX, DFW) and each D1 call to the Sydney primary took 158 to 244 ms. A fresh build makes 14 such calls since #496.

Option Evidence Verdict
Smart Placement for the consumer Placement "only affects the execution of fetch event handlers". Queue consumers are excluded. Cannot work
D1 read replicas for the build Replica reads took 11 to 60 ms in traces, but most of the 14 build calls are writes, which go to the primary. The first read must see the row the POST just wrote. Saves under 0.5 s
Build in the POST after its response No queue delivery. The request runs where the client reached Cloudflare. From Sydney, the same D1 calls took 8 to 36 ms. Chosen

The POST now runs processArtifactBuild in waitUntil, with the same dependencies the consumer uses. The queue stays the fallback:

  • A delayed message goes out first. A Worker keeps a request alive 30 s after its response, so the consumer takes over a build the runtime stops 35 s later. A finished build makes that message a single D1 read.
  • A build that throws goes to the queue at once, for its retry ladder.
  • A build that follows an earlier build of the same Skill goes back on the queue after the wait it names, as in the consumer.
  • When neither the request nor the queue can take the build, the Resolution fails as a retryable SERVICE_UNAVAILABLE, as in perf(artifact-delivery): answer Resolution polls when the build moves #497.

Builds in requests are not limited by the consumer's max_concurrency. The read App's GitHub quota still bounds cold builds.

A run that reaches Cloudflare far from Sydney still pays the D1 round trips. The Smart Placement header on skilld.dev responses reads local-SYD from Sydney today, so placement does not move requests toward the database. Removing that cost for every region needs a builder Worker placed near Sydney with placement.region, a new deploy unit.

Where a build runs: the POST request builds after its response and sends a delayed fallback message to the queue

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

The queue delivered a build 1.2 s after the request at the median and
3.4 s at worst. Its consumer ran in US colos, 158 to 244 ms from the D1
primary in Sydney per call, and placement cannot move a queue consumer.

The POST now runs the build after its response, in waitUntil, where the
request reached Cloudflare. A delayed queue message goes out first, so
the queue resumes a build the runtime stops. A build that throws goes to
the queue at once, and one that follows an earlier build goes back after
its wait, as in the consumer.
@harlan-zw
harlan-zw added this pull request to stack #509 October 6, 2026 16:22
@harlan-zw harlan-zw added the harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. label Oct 6, 2026
@harlan-github-agent harlan-github-agent Bot added harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. harlan-agent-running An Agent holds a Task on this issue or pull request right now. and removed harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. harlan-agent-running An Agent holds a Task on this issue or pull request right now. labels Oct 6, 2026
…1eb0: schedule buildAfterResponse work through runAfterResponse, since H3Event has no waitUntil on h3 1.15. Update the route tests to the delayed fallback send, the throw
@harlan-github-agent harlan-github-agent Bot added the harlan-agent-running An Agent holds a Task on this issue or pull request right now. label Oct 6, 2026
@harlan-github-agent

harlan-github-agent Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🤖 MERGED

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Last updated: 2026-10-07 01:20 UTC.

GitHub merged this pull request.

  • Logged (20/100): A build that throws now runs two independent queue retry ladders for one Resolution. View code
    • Ask an agent to verify and fix this finding

408296b2-de99-462d-bda2-b77954738896

Selected findings run after merge and open separate pull requests.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-ready The automated Review passed every gate on this head commit. and removed harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Oct 6, 2026

@harlan-github-agent harlan-github-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Harlan Agent Kit posted this automated review. AI open source policy.

Automated Review: READY.

Read the Review results

@harlan-zw
harlan-zw merged commit a127d10 into main Oct 7, 2026
7 checks passed
harlan-zw added a commit that referenced this pull request Oct 7, 2026
#508 builds a Resolution in its own request. Keep its after-response
build beside the linked-files header, and give its tests the
linked_files column.
@harlan-github-agent harlan-github-agent Bot removed the harlan-agent-ready The automated Review passed every gate on this head commit. label Oct 7, 2026
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