|WARNING| [v1] dts: resolve variance in performance reporting

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Fri Jul 17 17:09:18 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/166776

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-07-17

# DPDK Patch Review

## Summary
This patch modifies the DTS (DPDK Test Suite) single core forward performance test to reduce variance by changing from a single 30-second test run to 5 runs of 5 seconds each, averaging the results.

---

## Errors

None identified.

---

## Warnings

### 1. Accumulation logic may be incorrect
**Location:** `dts/tests/TestSuite_single_core_forward_perf.py:80`

The accumulation pattern uses `+=` but divides by `repetitions * 1_000_000` at the end. This appears to be calculating the average rx_pps and then converting to MPPS, which is mathematically correct. However, the variable name `rx_avg` and the comment suggest this is averaging MPPS values, when it's actually summing pps values.

**Suggested fix:** Consider renaming for clarity or adding a comment:
```python
# Sum rx_pps from all repetitions, then convert average to MPPS
rx_pps_sum: float = 0
for _ in range(repetitions):
    stats = assess_performance_by_packet(packet=packet, duration=5)
    rx_pps_sum += stats.rx_pps
return rx_pps_sum / (repetitions * 1_000_000)
```

Or if you want to maintain the current structure:
```python
rx_pps_sum: float = 0  # Sum of packets per second across all repetitions

for _ in range(repetitions):
    # Transmit for 5 seconds.
    stats = assess_performance_by_packet(packet=packet, duration=5)
    rx_pps_sum += stats.rx_pps
return rx_pps_sum / (repetitions * 1_000_000)
```

### 2. Hardcoded repetitions value
**Location:** `dts/tests/TestSuite_single_core_forward_perf.py:135`

The number of repetitions (5) is hardcoded in the test method call. Consider making this configurable via test parameters for flexibility in tuning the variance/runtime tradeoff.

**Suggested improvement:**
```python
# In set_up_suite or similar:
self.perf_test_repetitions = getattr(self.config, 'perf_test_repetitions', 5)

# Then use:
params["measured_mpps"] = round(
    self._transmit(testpmd, frame_size, repetitions=self.perf_test_repetitions), 3
)
```

---

## Info

### 1. Documentation update consideration
The docstring for `_transmit()` mentions transmitting for a duration but doesn't clarify that this is now per-repetition. The comment "Transmit for 5 seconds" inside the loop is helpful, but the function-level documentation could be more explicit:

```python
def _transmit(self, testpmd: TestPmd, frame_size: int, repetitions: int = 1) -> float:
    """Transmit packets and measure forwarding performance.

    Args:
        testpmd: The testpmd shell to use for forwarding packets.
        frame_size: The size of the frame to transmit.
        repetitions: The number of times to repeat the transmission test.
                    Each repetition runs for 5 seconds.

    Returns:
        The average MPPS (millions of packets per second) forwarded by the SUT
        across all repetitions.
    """
```

### 2. Type annotation consistency
The return type annotation is `float` which is correct, but the intermediate variable `rx_avg` could benefit from explicit type annotation for consistency with DPDK style (already present, which is good).

---

## Conclusion

The patch is functionally correct and addresses the stated goal of reducing variance in performance measurements. The main concerns are around code clarity (variable naming) and potential for future configuration flexibility. No correctness bugs or critical issues identified.

**Overall assessment:** The patch is acceptable with minor suggestions for improvement in clarity and maintainability.


More information about the test-report mailing list