Review Board 2.0.15


stats: organize and clarify resettable stats

Review Request #3235 - Created Nov. 23, 2015 and updated

Information
Lena Olson
gem5
default
Reviewers
Default
Changeset 11230:374d79447577
---------------------------
stats: organize and clarify resettable stats

Some stats (e.g. sim_insts) were traditionally not reset, because they were
intended for simulator-level measurement. However, some other stats (e.g.
sim_ticks) WERE reset. In addition, some derived stats used both reset and
unreset stats in the calculation, resulting in nonsense values. This patch
creates two sets of overall stats: one set that respects reset, and is useful
for measuring the simulated program, and one set that does not reset, useful for
studying the simulator itself.  The non-resettable stats are prefixed with
"simulator_", as they behave different from other stats.

   

Issue Summary

2 2 0 0
Review request changed
Updated (Jan. 6, 2016, 2:07 p.m.)

Change Summary:

Here's an attempt at duplicating and splitting up the stats. I had trouble deciding what to call things or how to make it clear which stats were which, so if anyone has better ideas of how to do that, I'd be happy to hear them.

Summary:

-stats: make sim_insts and sim_ops respect stats reset
+stats: organize and clarify resettable stats

Description:

~  

Changeset 11229:f4b15e5109f9

  ~

Changeset 11230:374d79447577

   
~  

stats: make sim_insts and sim_ops respect stats reset

  ~

stats: organize and clarify resettable stats

   
~  

Because sim_insts and sim_ops were being calculated using the ThreadState

~   variable numInst/numOp (type Counter) rather than numInsts/numOps (type
~   Stats::Scalar), they were not getting reset. This behavior is confusing because
~   almost all other entries in the stats file do get reset (with the exception of
~   final_tick, which notes it is never reset in the stats file). It also leads to
~   incorrect behavior with stats like host_inst_rate, which reset the host time but
~   not the instructions executed. This patch resets sim_insts and sim_ops.

  ~

Some stats (e.g. sim_insts) were traditionally not reset, because they were

  ~ intended for simulator-level measurement. However, some other stats (e.g.
  ~ sim_ticks) WERE reset. In addition, some derived stats used both reset and
  ~ unreset stats in the calculation, resulting in nonsense values. This patch
  ~ creates two sets of overall stats: one set that respects reset, and is useful
  ~ for measuring the simulated program, and one set that does not reset, useful for
  ~ studying the simulator itself. The non-resettable stats are prefixed with
  + "simulator_", as they behave different from other stats.

Diff:

Revision 2 (+238 -12)

Show changes

Posted (Jan. 11, 2016, 3:52 p.m.)

The implementation here looks good. Thanks for putting this together!

Just a couple small requests below.

src/cpu/kvm/base.cc (Diff revision 2)
 
 

We should probably check with Andreas Sandberg on this one. It looks like ctrInsts is already a cummulative stat for the KVM CPU. This might be required by the KVM CPU for fast-forwarding correctness? This could cause changes in KVM correctness and/or regressions (if any are maintained). Hopefully, it is harmless to allow the stat to reset, though?

  1. I think it should be okay -- ctrInsts and numInsts both already existed and I don't modify them, I just changed which is used by totalInsts(), which looks like it never gets called by anything besides the stats stuff. Another pair of eyes wouldn't hurt though.

  2. This seems fine to me both ctrInsts and numInsts are incremented with the value from hwInstructions performance counter.

src/cpu/minor/cpu.cc (Diff revision 2)
 
 

Just a note that this is interesting... looks like this fixes an inconsistency: MinorCPU appears to collect inst stats cummulatively, while the other CPUs use resettable stats (another indicator that this patch will help with clarity!)

  1. I think all of them used numInst (which is a counter) originally, and I changed them all to numInsts (which is a stat)? It's easy to get numInst and numInsts confused -- there being a counter called numInst and a stat called numInsts as members of the same struct is just asking for trouble IMO, but I didn't have a better idea so I left them as is.

src/sim/stat_control.cc (Diff revision 2)
 
 

I'm hoping that we could use stat names that are a little more self-evident for these. Maybe instead of 'simulatorXxxx'/'simulator_xxxx' we could use something like 'cummulativeSimXxxx'/'cumm_sim_xxxx'? That way the names more clearly indicate that the stats are accumulated throughout the whole simulation time rather than just the current stats period.

I do like that the descriptions say "not reset" also.

  1. I like cumulativeSim (and cumulative_sim, though it's long), as long as it's clear that it's different from final_tick -- it's cumulative over this invocation of the simulator, but not restored from checkpoints. Hopefully the note in the descriptions helps clarify that. Anyone else have opinions?

Posted (Jan. 21, 2016, 11:58 a.m.)

I'm glad you've taken the time to figure out what all these stats actually do. I like the direction, but a couple of comments.

First, can you add more comments to the code. Similar to what's in o3/cpu.hh. It would be good if this was at least in all of the .hh files, maybe in the .cc files too. Related to my next comment, but if the names aren't obvious, they should at least be very well commented.

Second, these names make no sense to me. Why are "sim*" reset and "simulator*" not reset? Isn't "sim" short for "simulator" or "simulation"?

My suggestion: For statitics that are reset every time, have no prefix at all so there would be ticks, instructions, etc. We already know the came from a simulator/simulation.
For the statistics that don't reset you could call them "total*" (i.e., totalTicks, totalInsts).
And I think finalTicks is fine as it is with its extra comments.