Skip to content
  • Chandler Carruth's avatar
    Add time getters to the process interface for requesting the elapsed · ef7f968e
    Chandler Carruth authored
    wall time, user time, and system time since a process started.
    
    For walltime, we currently use TimeValue's interface and a global
    initializer to compute a close approximation of total process runtime.
    
    For user time, this adds support for an somewhat more precise timing
    mechanism -- clock_gettime with the CLOCK_PROCESS_CPUTIME_ID clock
    selected.
    
    For system time, we have to do a full getrusage call to extract the
    system time from the OS. This is expensive but unavoidable.
    
    In passing, clean up the implementation of the old APIs and fix some
    latent bugs in the Windows code. This might have manifested on Windows
    ARM systems or other systems with strange 64-bit integer behavior.
    
    The old API for this both user time and system time simultaneously from
    a single getrusage call. While this results in fewer system calls, it
    also results in a lower precision user time and if only user time is
    desired, it introduces a higher overhead. It may be worthwhile to switch
    some of the pass timers to not track system time and directly track user
    and wall time. The old API also tracked walltime in a confusing way --
    it just set it to the current walltime rather than providing any measure
    of wall time since the process started the way buth user and system time
    are tracked. The new API is more consistent here.
    
    The plan is to eventually implement these methods for a *child* process
    by using the wait3(2) system call to populate an rusage struct
    representing the whole subprocess execution. That way, after waiting on
    a child process its stats will become accurate and cheap to query.
    
    llvm-svn: 171551
    ef7f968e
Loading