Skip to content

perf(upgrade): download release assets over parallel ranges - #381

Merged
runkids merged 3 commits into
mainfrom
runkids/parallel-release-download
Oct 4, 2026
Merged

runkids merged 3 commits into
mainfrom
runkids/parallel-release-download

Conversation

@runkids

@runkids runkids commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix — slow downloads, filed as a performance fix (perf)
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Linked Issue

None. Found while the desktop app's CLI upgrade took 3+ minutes.

Summary

release-assets.githubusercontent.com throttles each connection on some networks (~80 KB/s here, while Cloudflare/npm serve 10 MB in 0.4 s). skillshare upgrade and the first skillshare ui of a new version both waited minutes on it.

  • New utils.DownloadToFile: probes with Range: bytes=0-0. A 206 answer → 8 ranges in parallel from the redirected URL, each with its own connection (a shared HTTP/2 connection stayed throttled: 97 s), written with io.NewOffsetWriter, exact byte counts checked; the first error cancels the rest. A 200 answer streams that response as before (no extra request). Size limit enforced before downloading.
  • downloadArchive (upgrade) and uidist.downloadToTemp use it. Checksum verification unchanged.
  • Docs: UI assets are about 2 MB, not 1 MB (en, ja, ko, zh-Hans, zh-Hant).

Timing (devcontainer, skillshare_0.24.1_darwin_arm64.tar.gz, 9,665,580 B): single connection 170.7 s → 8 ranges 25.0 s; sha256 matches checksums.txt both ways.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — 4 tests in internal/utils/download_test.go (ranged reassembly, no-range fallback, failed range, oversize); full make check passed in the devcontainer; go test -race ./internal/utils/ passed
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Not run: website build, E2E runbooks.

release-assets.githubusercontent.com throttles each connection on some
networks. The 9.6 MB darwin_arm64 archive took 122-171 s over one
connection but 25 s as 8 ranges, each on its own connection, with an
identical checksum. `skillshare upgrade` and the first `skillshare ui`
of a new version both waited minutes on that download.

DownloadToFile probes with `Range: bytes=0-0`; a 206 answer splits the
file into ranges fetched in parallel from the redirected URL, and a 200
answer streams the single response as before, so servers without range
support cost no extra request. Size limits and checksum verification are
unchanged.

The UI asset download is about 2 MB now, so the docs no longer say 1 MB.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T05:58:22.252952Z 22d76ee Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfe3729f26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/utils/download.go Outdated
Comment on lines +98 to +100
transport := http.DefaultTransport.(*http.Transport).Clone()
defer transport.CloseIdleConnections()
client := &http.Client{Timeout: timeout, Transport: transport}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the supplied client's transport for range requests

When the provided client uses a custom transport—for example, a private CA, authenticated proxy, or custom dialer—the probe succeeds through that transport, but every parallel request is rebuilt from http.DefaultTransport. Those requests then bypass the caller's network configuration and can fail even though the initial request succeeded; clone the supplied *http.Transport (or otherwise preserve the client's request behavior) while still creating distinct connections.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 22d76ee. Each range now copies the caller's client with a clone of its *http.Transport (rangeClient), so a private CA, proxy or custom dialer applies to every range while each range still gets its own connection; a transport that is not an *http.Transport is shared as is. Covered by TestDownloadToFile_RangesKeepTheClientTransport, which downloads from an httptest.NewTLSServer with srv.Client() and failed before the fix with x509: certificate signed by unknown authority.

Each range built its client from http.DefaultTransport, so a caller's
custom transport (private CA, authenticated proxy, custom dialer) only
applied to the probe. The ranges then failed or bypassed the caller's
network setup even though the probe succeeded. Each range now copies the
caller's client with a clone of its *http.Transport, which keeps those
settings and still gives the range its own connection. A transport that
cannot be cloned is shared as is.
@runkids

runkids commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 22d76eee25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@runkids
runkids merged commit 887461b into main Oct 4, 2026
8 checks passed
@runkids
runkids deleted the runkids/parallel-release-download branch October 4, 2026 06:03
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