0

Is there some performance counter or similar available which can help quantify the extent to which two hyperthreads on the same core are competing with each other for execution resources?

Use case: in a shared infrastructure environment like Kubernetes, I may be able to request that my process has "1 CPU" of capacity. However with hyperthreading in play this is not a physical core but a logical CPU, and the throughput of that core may vary by as much as a factor of 2 depending on what's scheduled to run on the other logical CPU corresponding to the other hyperthread of the same physical core. Is there some metric which can quantify how much time has been spent stalled waiting on the other hyperthread?

Another use case: depending on the nature of the workload and how much it stands to gain from hyperthreading, average CPU utilization may not be a good indication of available capacity. For a workload that gets no benefit from hyperthreading at all, loading the host beyond 50% CPU utilization may not increase throughput at all. What metrics could I use to determine how much real execution resource, and not just idle logical CPU time, is available?

Phil Frost
  • 3,668
  • 21
  • 29

1 Answers1

-1

Probably, as everything is in source code, you can implement such a counter....

Of course, implementation depends on what you do want to monitor,

  • a counter per shared resource,
  • a global counter per function,
  • a counter per operation type (lock/unlock)

Anyway, a counter (in/de)crement must be atomic in essence, and should be contained also (a spinlock?), making your code slower, so that's several reasons to not include them by default.

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31
  • I think the question is pretty clear about what I want to monitor: contention from competing hyperthreads. I'm afraid you've missed the point entirely. Implementing a counter for something the code does is easy. A counter for an implementation detail of the CPU over which you have no control within the program, not so much. – Phil Frost Nov 15 '18 at 15:07