Skip to content

[Windows] Implement support for the cpu-clock perf pseudo-counter #897

Open
@wesleywiser

Description

@wesleywiser

The Linux perf tool has a counter called cpu-clock which is basically just the total time the process was running on each thread. (As a simple example, suppose a process runs for 3 seconds on 1 core and, at the same time, 1 second on another core, then the cpu-clock would read 4 seconds)

This counter isn't backed by a hardware performance counter, rather it is a metric derived from some hardware performance counters and as such, doesn't exist on Windows. However, we can replicate the counter ourselves.

To do that, we'll need to keep track of the times each thread we care about spends active on a core and sum the total times together. We may be able to use the Timestamp data already collected in the trace file for this purpose or we may need to use the Time (or TimerFixed?) PMC.

// FIXME(wesleywiser): We should be properly calculating this value by taking the total time
// each rustc thread runs per core and adding them togther. This placeholder value is here
// so that we can still render the detailed query statistics page (although the "Time (%)"
// column will show the wrong value).
cpu_clock: 1.0,

// FIXME(wesleywiser): see comment in `<Counters as Default>::default()`.
cpu_clock: 0.0,

After this is implemented, the detailed self-profile query results page should show reasonable numbers in the total "Time %" cell.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsAn issue specific to the Windows OS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions