This patch adds in a a new flag (--benchmark-subprocess) that enables
benchmarking within a subprocess. This is necessary for implementing the
plane described in our annotation RFC
(https://discourse.llvm.org/t/rfc-memory-annotations-for-llvm-exegesis/69554)
as we need to have a lot more control over the memory layout of the
execution environment than is possible by doing everything in a single
process.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This patch adds in the subprocess benchmarking mode (phase 1 of the RFC linked in the description). I can understand some hesitancy on getting this pushed through since the RFC hasn't been discussed thoroughly, so I can definitely wait until we have everything nailed down there if necessary. After this patch, I plan on working on an assembly test harness so that we have the control over memory that we need and then I plan on adding the proposed annotations.
Hopefully this code isn't too hacky and review isn't too difficult. I have never worked with low level process control functions on Linux in a production environment before (e.g., still have never experienced most of the footguns of fork()).
There are two minor issues with this patch that I still need to address, namely that it only supports sending a single CounterValue from the benchmarking process to the llvm-exegesis process (so LBR doesn't work), and that there are some slight systematic differences in measurements between the subprocess mode and the in-process mode (at least on my system, dual socket E5-2670 sandy bridge). I haven't done a ton of investigation into why this issue is occurring, but it is relatively minor (only about a 1% difference), and I imagine should be alleviated once we switch to the assembly test harness (if that's the route we end up going down).
Planning on reworking the way the performance counters are passed between the parent and child process to allow for better reading in the parent process/easier usage in the child process as the first annotation implementation evolves.