Skip to content

test(vsock): add latency test#5603

Open
aaron-ang wants to merge 2 commits intofirecracker-microvm:mainfrom
aaron-ang:vsock-latency-perf
Open

test(vsock): add latency test#5603
aaron-ang wants to merge 2 commits intofirecracker-microvm:mainfrom
aaron-ang:vsock-latency-perf

Conversation

@aaron-ang
Copy link

@aaron-ang aaron-ang commented Jan 6, 2026

Create simple ping latency test in vsock_helper host tools

Changes

Close #2353.

Reason

  • Add latency measurement to the vsock performance suite by extending vsock_helper.c with ping and ping-uds commands that emit per‑request RTTs
  • Add latency tests in test_vsock.py that exercise guest -> host and host -> guest paths.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@aaron-ang
Copy link
Author

hi @raduiliescu @Manciukic could you please take a look?

@Manciukic
Copy link
Contributor

Hey @aaron-ang, thanks for the contribution! I only had a very quick look, but I was wondering whether we need both ping and ping-uds. Intuitively, the ping is symmetric and already measures both g2h and h2g so I would think only the ping mode is needed. Did you notice any difference in measurement between the two tests? Can you share some data/output on your reference machine to get a feel on how that looks like?

@JamesC1305 JamesC1305 added the Status: Awaiting author Indicates that an issue or pull request requires author action label Jan 14, 2026
@JamesC1305
Copy link
Contributor

Hi @aaron-ang,

Just wanted to see if you had a chance to read our previous update? Let us know if you need anything more from us.

Thank you!

@aaron-ang
Copy link
Author

Hi @JamesC1305, apologies as I have been really busy the past few weeks. I will look into this within this week.

Create simple ping latency test in vsock_helper host tools

Signed-off-by: Aaron Ang <aaron.angyd@gmail.com>
@aaron-ang
Copy link
Author

aaron-ang commented Feb 26, 2026

My setup: "cpu_model": "Intel(R) N100", "host_kernel": "linux-6.17", "rootfs": "ubuntu-24.04.squashfs".

I did some stats aggregation (ping-uds has slightly higher overall latency):

Directionnmean (µs)median (µs)p95 (µs)p99 (µs)
g2h/ping3600633.0375.52201.33012.1
h2g/ping-uds3600861.5508.02610.23427.1

I think both should be kept.ping (g2h test) measures guest-initiated AF_VSOCK traffic to a host echo server, while ping-uds (h2g test) measures host-initiated UDS CONNECT traffic into Firecracker and then to a guest echo server.

Copy link
Contributor

@Manciukic Manciukic left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a nit to reduce boilerplate code. I need to double check this works, I will kickoff our performance CI as well so we can run these tests


@pytest.mark.nonci
@pytest.mark.parametrize("vcpus", [1, 2], ids=["1vcpu", "2vcpu"])
def test_vsock_latency_g2h(uvm_plain_acpi, vcpus, metrics, bin_vsock_path):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we can avoid some duped code by having the test setup in a separate fixture for all the tests in the file

@pytest.fixture
def vsock_uvm(uvm_plain_acpi, request):
    """Fixture to initialize a microVM with vsock device."""
    vcpus = request.param if hasattr(request, "param") else 1
    mem_size_mib = 1024

    vm = uvm_plain_acpi
    vm.spawn(log_level="Info", emit_metrics=True)
    vm.basic_config(vcpu_count=vcpus, mem_size_mib=mem_size_mib)
    vm.add_net_iface()
    vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path="/" + VSOCK_UDS_PATH)
    vm.start()
    vm.pin_threads(0)

    return vm

then it can be used as

@pytest.mark.parametrize("vsock_uvm", [1, 2], indirect=True, ids=["1vcpu", "2vcpu"])

@Manciukic
Copy link
Contributor

Manciukic commented Mar 4, 2026

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.12%. Comparing base (dfa6efa) to head (e7912cd).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5603   +/-   ##
=======================================
  Coverage   83.12%   83.12%           
=======================================
  Files         277      277           
  Lines       29423    29423           
=======================================
  Hits        24459    24459           
  Misses       4964     4964           
Flag Coverage Δ
5.10-m5n.metal 83.41% <ø> (ø)
5.10-m6a.metal 82.75% <ø> (?)
5.10-m6g.metal 80.12% <ø> (ø)
5.10-m6i.metal 83.42% <ø> (ø)
5.10-m7a.metal-48xl 82.74% <ø> (+<0.01%) ⬆️
5.10-m7g.metal 80.12% <ø> (ø)
5.10-m7i.metal-24xl 83.39% <ø> (+<0.01%) ⬆️
5.10-m7i.metal-48xl 83.39% <ø> (ø)
5.10-m8g.metal-24xl 80.12% <ø> (ø)
5.10-m8g.metal-48xl 80.12% <ø> (ø)
5.10-m8i.metal-48xl 83.38% <ø> (-0.01%) ⬇️
5.10-m8i.metal-96xl 83.39% <ø> (-0.01%) ⬇️
6.1-m5n.metal 83.44% <ø> (-0.01%) ⬇️
6.1-m6a.metal 82.78% <ø> (-0.01%) ⬇️
6.1-m6g.metal 80.12% <ø> (-0.01%) ⬇️
6.1-m6i.metal 83.44% <ø> (+<0.01%) ⬆️
6.1-m7a.metal-48xl 82.77% <ø> (ø)
6.1-m7g.metal 80.12% <ø> (-0.01%) ⬇️
6.1-m7i.metal-24xl 83.45% <ø> (ø)
6.1-m7i.metal-48xl 83.45% <ø> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 80.12% <ø> (ø)
6.1-m8g.metal-48xl 80.12% <ø> (ø)
6.1-m8i.metal-48xl 83.46% <ø> (ø)
6.1-m8i.metal-96xl 83.45% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting author Indicates that an issue or pull request requires author action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing] Vsock latency performance test

3 participants