Add libuv-backed MultiUv for event-driven concurrent HTTP transfers - #48
Draft
jiacai2050 with Copilot wants to merge 3 commits into
Draft
Add libuv-backed MultiUv for event-driven concurrent HTTP transfers#48jiacai2050 with Copilot wants to merge 3 commits into
jiacai2050 with Copilot wants to merge 3 commits into
Conversation
Adds MultiUv — a new event-driven alternative to the blocking Multi interface: - src/MultiUv.zig: Uses curl_multi_socket_action + libuv uv_poll_t/uv_timer_t for epoll/kqueue-based I/O notification instead of curl_multi_poll - src/root.zig: Conditionally exports MultiUv (void when -Dlibuv=false) - build.zig: Adds -Dlibuv=true/false option, multi-uv example, libuv linking - examples/multi_uv.zig: Demonstrates three concurrent GETs via uv_run() - Makefile: Adds run-libuv target Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Integrate with libuv for better performance
Add libuv-backed MultiUv for event-driven concurrent HTTP transfers
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
Multiinterface usescurl_multi_poll— a blocking poll — making it unsuitable for integration with external event loops or high-concurrency workloads. This PR addsMultiUv, which wires libcurl's socket-action API into libuv's epoll/kqueue-based event loop.New:
src/MultiUv.zigImplements the
curl_multi_socket_actionintegration pattern:CURLMOPT_SOCKETFUNCTION→ creates/destroysuv_poll_thandles per curl socketCURLMOPT_TIMERFUNCTION→ drives curl's timeout via a shareduv_timer_tCompletionCallbackfired per-transfer inside the event loop (no polling loop needed)create/destroy) to keep libuv handle addresses stableBuild system (
build.zig)New
-Dlibuv=trueflag (default:false):has_libuvintobuild_info;root.zigexportsMultiUvasvoidwhen disabled, so uv headers are never required without the flagmodule.linkSystemLibrary("uv", .{})propagates-luvto all artifacts that import the modulerun-multi-uvstep and libuv check/test targetssrc/root.zigDead-branch
@importmeansuv.his never processed unless the flag is set.examples/multi_uv.zigThree concurrent GETs via
uv_default_loop()+uv_run(), mirroring the existingmulti.zigwriter pattern.MakefileAdds
run-libuvtarget (zig build run-multi-uv -Dlibuv=true).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
8.8.8.8REDACTED, pid is -1(packet block)ziglang.org/usr/bin/curl curl -s REDACTED --output /tmp/zig-0.15.2.tar.xz(dns block)/usr/bin/ping ping -c 1 ziglang.org(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.