24.10.3. gem5 m5out/stats.txt file

This file contains important statistics about the run:

cat "$(./getvar --arch aarch64 m5out_dir)/stats.txt"

Whenever we run m5 dumpstats or when fs.py and se.py are exiting (TODO other scripts?), a section with the following format is added to that file:

---------- Begin Simulation Statistics ----------
[the stats]
---------- End Simulation Statistics   ----------

That file contains several important execution metrics, e.g. number of cycles and several types of cache misses:

system.cpu.numCycles
system.cpu.dtb.inst_misses
system.cpu.dtb.inst_hits

For x86, it is interesting to try and correlate numCycles with:

In LKMC f42c525d7973d70f4c836d2169cc2bd2893b4197 gem5 5af26353b532d7b5988cf0f6f3d0fbc5087dd1df, the stat file for a C hello world:

./run --arch aarch64 --emulator gem5 --userland userland/c/hello.c

which has a single dump done at the exit, has size 59KB and stat lines of form:

final_tick                                   91432000                       # Number of ticks from beginning of simulation (restored from checkpoints and never reset)

We can reduce the file size by adding the ?desc=False magic suffix to the stat flie name:

--stats-file stats.txt?desc=false

as explained in:

gem5.opt --stats-help

and this reduces the file size to 39KB by removing those excessive comments:

final_tick                                   91432000

although trailing spaces are still prse

We can further reduce this size by removing spaces from the dumps with this hack:

         ccprintf(stream, " |%12s %10s %10s",
                  ValueToString(value, precision), pdfstr.str(), cdfstr.str());
     } else {
-        ccprintf(stream, "%-40s %12s %10s %10s", name,
-                 ValueToString(value, precision), pdfstr.str(), cdfstr.str());
+        ccprintf(stream, "%s %s", name, ValueToString(value, precision));
+        if (pdfstr.rdbuf()->in_avail())
+            stream << " " << pdfstr.str();
+        if (cdfstr.rdbuf()->in_avail())
+            stream << " " << cdfstr.str();

         if (descriptions) {
             if (!desc.empty())

and after that the file size went down to 21KB.