【问题标题】:Meaning of the benchmark variables in snakemakesnakemake中基准变量的含义
【发布时间】:2017-10-18 15:03:28
【问题描述】:

我在我的 snakemake 工作流程中的一些规则中包含了 benchmark 指令,生成的文件具有以下标头:

s   h:m:s   max_rss max_vms max_uss max_pss io_in   io_out  mean_load

The only documentation I've found 提到了一个“基准 txt 文件(其中将包含一个制表符分隔的运行时间表和 MiB 中的内存使用情况)”。

我可以猜测第 1 列和第 2 列是显示执行规则所用时间的两种不同方式(以秒为单位,并转换为小时、分钟和秒)。

io_inio_out 可能与磁盘读写活动有关,但它们是以什么单位衡量的?

其他的是什么?这是否记录在某处?

编辑:查看源代码

我在/snakemake/benchmark.py 中找到了以下代码,这很可能是基准数据的来源:

def _update_record(self):
    """Perform the actual measurement"""
    # Memory measurements
    rss, vms, uss, pss = 0, 0, 0, 0
    # I/O measurements
    io_in, io_out = 0, 0
    # CPU seconds
    cpu_seconds = 0
    # Iterate over process and all children
    try:
        main = psutil.Process(self.pid)
        this_time = time.time()
        for proc in chain((main,), main.children(recursive=True)):
            meminfo = proc.memory_full_info()
            rss += meminfo.rss
            vms += meminfo.vms
            uss += meminfo.uss
            pss += meminfo.pss
            ioinfo = proc.io_counters()
            io_in += ioinfo.read_bytes
            io_out += ioinfo.write_bytes
            if self.bench_record.prev_time:
                cpu_seconds += proc.cpu_percent() / 100 * (
                    this_time - self.bench_record.prev_time)
        self.bench_record.prev_time = this_time
        if not self.bench_record.first_time:
            self.bench_record.prev_time = this_time
        rss /= 1024 * 1024
        vms /= 1024 * 1024
        uss /= 1024 * 1024
        pss /= 1024 * 1024
        io_in /= 1024 * 1024
        io_out /= 1024 * 1024
    except psutil.Error as e:
        return
    # Update benchmark record's RSS and VMS
    self.bench_record.max_rss = max(self.bench_record.max_rss or 0, rss)
    self.bench_record.max_vms = max(self.bench_record.max_vms or 0, vms)
    self.bench_record.max_uss = max(self.bench_record.max_uss or 0, uss)
    self.bench_record.max_pss = max(self.bench_record.max_pss or 0, pss)
    self.bench_record.io_in = io_in
    self.bench_record.io_out = io_out
    self.bench_record.cpu_seconds += cpu_seconds

所以这似乎来自psutil提供的功能。

【问题讨论】:

    标签: psutil snakemake


    【解决方案1】:

    snakemake 中的基准测试当然可以更好地记录下来,但 psutil 已记录在案 here:

    get_memory_info()
    Return a tuple representing RSS (Resident Set Size) and VMS (Virtual Memory Size) in bytes.
    On UNIX RSS and VMS are the same values shown by ps. 
    On Windows RSS and VMS refer to "Mem Usage" and "VM Size" columns of taskmgr.exe.
    
    psutil.disk_io_counters(perdisk=False)
    
    Return system disk I/O statistics as a namedtuple including the following attributes:
        read_count: number of reads
        write_count: number of writes
        read_bytes: number of bytes read
        write_bytes: number of bytes written
        read_time: time spent reading from disk (in milliseconds)
        write_time: time spent writing to disk (in milliseconds)
    

    您找到的代码确认所有内存使用情况和 IO 计数都以 MB 为单位报告(= 字节 * 1024 * 1024)。

    【讨论】:

      【解决方案2】:

      我将把它留在这里以供将来参考。

      通读

      如前所述:

      colname type (unit) description
      s float (seconds) Running time in seconds
      h:m:s string (-) Running time in hour, minutes, seconds format
      max_rss float (MB) Maximum "Resident Set Size”, this is the non-swapped physical memory a process has used.
      max_vms float (MB) Maximum “Virtual Memory Size”, this is the total amount of virtual memory used by the process
      max_uss float (MB) “Unique Set Size”, this is the memory which is unique to a process and which would be freed if the process was terminated right now.
      max_pss float (MB) “Proportional Set Size”, is the amount of memory shared with other processes, accounted in a way that the amount is divided evenly between the processes that share it (Linux only)
      io_in float (MB) the number of MB read (cumulative).
      io_out float (MB) the number of MB written (cumulative).
      mean_load float (-) CPU usage over time, divided by the total running time (first row)
      cpu_time float(-) CPU time summed for user and system

      【讨论】:

      • 咦,我怎么在io_out中有0.02这样的值?操作数应该是一个整数,不是吗?
      • 根据@heathobrien的回答,io_inio_out对应的是“读MB数”和“写MB数”,所以它们也在MB中。
      • 你是对的,我从文档中读到了一些东西。我编辑了原件以反映正确的测量结果。
      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2017-02-01
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      相关资源
      最近更新 更多