examples/vsock-latency: reproducer for first-connection vsock delay#683
Draft
smoser wants to merge 2 commits into
Draft
examples/vsock-latency: reproducer for first-connection vsock delay#683smoser wants to merge 2 commits into
smoser wants to merge 2 commits into
Conversation
The first host-to-guest vsock round trip after VM start blocks until
libkrun's vsock reaper TTL fires (src/devices/src/virtio/vsock/reaper.rs:10,
currently 5 s). The first host connect() succeeds at the unix layer
immediately, but the first read() blocks for the full reaper window
before libkrun closes the unix socket with EOF. A second connect()
immediately afterwards uses a fresh proxy and completes in <1 ms.
The reproducer is ~400 lines of C in a new examples/vsock-latency/
subdirectory:
* guest.c tiny static AF_VSOCK listener; one ack byte per connect
* host.c libkrun setup + a timing thread that prints
phase: socket-created +<t>
phase: first-roundtrip-ok +<t> (attempts=<n>)
warm-roundtrip[0..3]: +<t>
* Makefile builds both; "make rootfs" pulls a busybox image
into ./rootfs/ via docker (a one-file rootfs is not
enough for libkrunfw's init)
* README.md what it measures, expected output, root cause
The host.c timing loop also honours PROBE_TIMEOUT_MS to apply
SO_RCVTIMEO per attempt (simulates a caller that wraps each probe
in a deadline). Measured trade-off on libkrunfw 5.4.0 / bundled
kernel 6.12.87:
PROBE_TIMEOUT_MS first-roundtrip-ok attempts
unset ~5340 ms 2
2000 ~2355 ms 2
100 ~425 ms 2
10 ~373 ms 3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
This was opened to share a reproducer for #684