<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77259>77259</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[llvm-exegesis] Measurement values sometimes doubled
</td>
</tr>
<tr>
<th>Labels</th>
<td>
tools:llvm-exegesis
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
boomanaiden154
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
boomanaiden154
</td>
</tr>
</table>
<pre>
Currently, there is a transient failure in `llvm-exegesis` where the measurement values that are reported are occasionally double what they should be. For example, take the following invocation:
```shell
llvm-exegesis -mode=latency -opcode-name=ADD64rr -execution-mode=subprocess -repetition-mode=loop
```
Typically something like the following will be reported:
```yaml
measurements:
- { key: latency, value: 1.006, per_snippet_value: 1.006 }
```
However, occasionally (on maybe 1 out of every 10 or 20 runs), the following is reported:
```yaml
measurements:
- { key: latency, value: 2.0051, per_snippet_value: 2.0051 }
```
All the performance counter reads are pretty similar to each other, just double of what they should be:
```
20103
20107
20104
20104
20103
20113
20104
20783
20103
20103
20103
20107
20097
20104
20103
20103
20103
20103
20103
20104
20065
20104
20103
20103
20104
20104
20104
20107
20116
20051
```
(Obtained by manually adding a print statement in `PerfHelper.cpp`)
Given that all these measurements are double what they should be, it seems to point to a systematic failure within `llvm-exegesis`.
There don't seem to be any issues with the generated code:
```x86
ee: 49 b8 10 27 00 00 00 00 00 00 movabsq $0x2710, %r8 # imm = 0x2710
f8: 4d 01 e4 addq %r12, %r12
fb: 49 83 c0 ff addq $-0x1, %r8
ff: 75 f7 jne 0xf8 <foo+0xf8>
```
(`0x2710` is the same is 10000, as expected for the default `--num-repetitions` value of 10000).
Interestingly, this only seems to occur in the subprocess execution mode. I have not been able to reproduce this with in the inprocess execution mode (at least not yet).
Additionally, this seems like it might be more systematic on certain platforms. On Cascade Lake, I am consistently getting measurements higher than they should be rather than sporadically. Not sure if that is related however.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.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