Repository: firecracker-microvm/firecracker
File: .buildkite/pipeline_perf.py (Python)

Code before:
if REVISION_A:
    # Enable automatic retry and disable manual retries to suppress spurious issues.
    retry["automatic"] = [
        {"exit_status": -1, "limit": 1},
        {"exit_status": 1, "limit": 1},
    ]
    retry["manual"] = False

pipeline = BKPipeline(
    # Boost priority from 1 to 2 so these jobs are preferred by ag=1 agents
    priority=2,
    # use ag=1 instances to make sure no two performance tests are scheduled on the same instance
    agents={"ag": 1},
    retry=retry,
)

tests = [perf_test[test] for test in pipeline.args.test or perf_test.keys()]
for test in tests:
    devtool_opts = test.pop("devtool_opts")
    test_path = test.pop("test_path")
    ab_opts = test.pop("ab_opts", "")
    devtool_opts += " --performance"
    pytest_opts = ""
    if REVISION_A:
        devtool_opts += " --ab"
        pytest_opts = f"{ab_opts} run build/{REVISION_A}/build/cargo_target/x86_64-unknown-linux-musl/release build/{REVISION_B}/build/cargo_target/x86_64-unknown-linux-musl/release --test {test_path}"
    else:
        # Passing `-m ''` below instructs pytest to collect tests regardless of
        # their markers (e.g. it will collect both tests marked as nonci, and
        # tests without any markers).
        pytest_opts += f" -m '' {test_path}"

    pipeline.build_group(
        command=pipeline.devtool_test(devtool_opts, pytest_opts),
        # and the rest can be command arguments
        **test,
    )


# Stores the info about pinning tests to agents with particular kernel versions.
# For example, the following:
# pins = {
#   "linux_6.1-pinned": {"instance": "m6i.metal", "kv": "linux_6.1"},
# }
# will pin steps running on instances "m6i.metal" with kernel version tagged "linux_6.1"
# to a new kernel version tagged "linux_6.1-pinned"
pins = {
    # TODO: Unpin when performance instability on m6i/5.10 has gone.
    "linux_5.10-pinned": {"instance": "m6i.metal", "kv": "linux_5.10"},
}


Review comment (suggestion):
should this be:

```
        pytest_opts = f"{ab_opts} run build/{REVISION_A}/build/cargo_target/$(uname -m)-unknown-linux-musl/release build/{REVISION_B}/build/cargo_target/$(uname -m)-unknown-linux-musl/release --test {test_path}"
```

to account for CPU architecture

Code after:
if REVISION_A:
    # Enable automatic retry and disable manual retries to suppress spurious issues.
    retry["automatic"] = [
        {"exit_status": -1, "limit": 1},
        {"exit_status": 1, "limit": 1},
    ]
    retry["manual"] = False

pipeline = BKPipeline(
    # Boost priority from 1 to 2 so these jobs are preferred by ag=1 agents
    priority=2,
    # use ag=1 instances to make sure no two performance tests are scheduled on the same instance
    agents={"ag": 1},
    retry=retry,
)

tests = [perf_test[test] for test in pipeline.args.test or perf_test.keys()]
for test in tests:
    devtool_opts = test.pop("devtool_opts")
    test_path = test.pop("test_path")
    ab_opts = test.pop("ab_opts", "")
    devtool_opts += " --performance"
    pytest_opts = ""
    if REVISION_A:
        devtool_opts += " --ab"
        pytest_opts = (
            f"{ab_opts} run build/{REVISION_A}/ build/{REVISION_B} --test {test_path}"
        )
    else:
        # Passing `-m ''` below instructs pytest to collect tests regardless of
        # their markers (e.g. it will collect both tests marked as nonci, and
        # tests without any markers).
        pytest_opts += f" -m '' {test_path}"

    pipeline.build_group(
        command=pipeline.devtool_test(devtool_opts, pytest_opts),
        # and the rest can be command arguments
        **test,
    )


# Stores the info about pinning tests to agents with particular kernel versions.
# For example, the following:
# pins = {
#   "linux_6.1-pinned": {"instance": "m6i.metal", "kv": "linux_6.1"},
# }
# will pin steps running on instances "m6i.metal" with kernel version tagged "linux_6.1"
# to a new kernel version tagged "linux_6.1-pinned"
pins = {
    # TODO: Unpin when performance instability on m6i/5.10 has gone.
    "linux_5.10-pinned": {"instance": "m6i.metal", "kv": "linux_5.10"},