Skip to content

Enable HTTP/2, connection reuse, and improve download parallelism#371

Open
aruiz wants to merge 3 commits intorpm-software-management:masterfrom
aruiz:master
Open

Enable HTTP/2, connection reuse, and improve download parallelism#371
aruiz wants to merge 3 commits intorpm-software-management:masterfrom
aruiz:master

Conversation

@aruiz
Copy link
Copy Markdown

@aruiz aruiz commented Mar 30, 2026

Summary

  • Default all transfers to HTTP/2 over TLS (CURL_HTTP_VERSION_2TLS) with transparent fallback to HTTP/1.1. Expose LRO_HTTPVERSION option as an escape hatch.
  • Add a CURLSH share handle per LrHandle to pool DNS cache and TCP+TLS connections across sequential lr_download() calls, avoiding redundant handshakes.
  • Raise default max parallel downloads from 3 to 5 and fix lr_download() to use the maximum parallelism across all target handles rather than just the first one.

Results

Benchmarked with dnf5 --setopt=build_cache=0 --refresh makecache against 9 enabled repos (Fedora 41, RPM Fusion, Chrome, VS Code, etc.):

Median Mean
Before (system librepo) 3.78s 3.85s
After (patched librepo) 2.43s 2.49s
Speedup 36% 35%

No changes required in dnf5 — all improvements take effect transparently.

Disclosure

This changeset was developed with assistance from Claude (Anthropic). Each commit is tagged Assisted-by: Claude.

Alberto Ruiz added 3 commits March 30, 2026 02:28
Set CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_2TLS in the default
curl easy handle factory so all transfers attempt HTTP/2 over TLS
with transparent fallback to HTTP/1.1. This eliminates redundant
TLS handshakes when downloading multiple files from the same mirror
via HTTP/2 multiplexing.

Also expose the setting as a new LRO_HTTPVERSION handle option
(with LRI_HTTPVERSION getinfo) so consumers can override per-handle
if needed. A new LrHttpVersionType enum provides the valid values.

Assisted-by: Claude
Each LrHandle now maintains a CURLSH share handle that pools DNS
cache and TCP+TLS connections across all curl easy handles spawned
from it. This allows connections to survive across sequential
lr_download() calls, avoiding redundant DNS lookups and TLS
handshakes when the same handle is used for multiple download
passes (e.g. dnf5's sync-check then full-download pattern).

A GMutex protects the shared state since curl_share can be
accessed concurrently by multiple easy handles within a
curl_multi session.

Assisted-by: Claude
Raise LRO_MAXPARALLELDOWNLOADS_DEFAULT from 3 to 5 to better
utilize HTTP/2 multiplexing and modern server capacity.

Fix the parallelism calculation in lr_download() to scan all
target handles and use the maximum maxparalleldownloads value,
rather than only considering the first target's handle. This
prevents a single handle with a conservative setting from
bottlenecking a mixed batch of downloads from multiple handles.

Assisted-by: Claude
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