AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 951226
Accepted
Craig Ringer
Craig Ringer
Asked: 2019-01-30 00:25:20 +0800 CST2019-01-30 00:25:20 +0800 CST 2019-01-30 00:25:20 +0800 CST

GNU“时间”中的 I/O 度量单位是什么?

  • 772

GNUtime具有可选的 I/O 测量显示:

TIME="%I:%O" /usr/bin/time cp filea fileb
0:5488

但它测量的是什么单位?有任何想法吗?说明书只说

   %I     Number of filesystem inputs by the process.

   %O     Number of filesystem outputs by the process.

这没什么帮助。

一些测试表明它可能是 512k 块,包括数据和元数据:

$ TIME="%I:%O" /usr/bin/time dd if=/dev/zero of=foo bs=1 count=1024
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.0120082 s, 85.3 kB/s
0:8

$ TIME="%I:%O" /usr/bin/time dd if=/dev/zero of=foo bs=1k count=1 conv=sync
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000354987 s, 2.9 MB/s
0:8

$ TIME="%I:%O" /usr/bin/time dd if=/dev/zero of=foo bs=1k count=1024
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.017763 s, 59.0 MB/s
0:2080

[craig@ayaki-localdomain personal-git]$ TIME="%I:%O" /usr/bin/time dd if=/dev/zero of=foo bs=1M count=1 conv=sync
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0052077 s, 201 MB/s
0:2048

但很高兴确认这一点。

有谁知道它来自哪里?

linux
  • 2 2 个回答
  • 293 Views

2 个回答

  • Voted
  1. Best Answer
    rsaxvc
    2020-07-09T13:00:04+08:002020-07-09T13:00:04+08:00

    从手册:

    The `%I' and `%O' values are allegedly only `real'
    input and output and do not include those supplied
    by caching devices. The meaning of `real' I/O reported
    by `%I' and `%O' may be muddled for workstations,
    especially diskless ones.
    

    所以单元在 I/O 中。也许源代码知道这意味着什么。从 time.c 中的汇总函数文档中:

    ...
    I == file system inputs (ru_inblock)
    ...
    O == file system outputs (ru_oublock)
    ...
    

    ru_inblock 和 ru_oblock 来自 getrusage。从 getrusage 手册:

    ru_inblock (since Linux 2.6.22)
      The number of times the filesystem had to perform input.
    
    ru_oublock (since Linux 2.6.22)
      The number of times the filesystem had to perform output.
    

    好吧,这并不是特别有用,但是 LKML 显示了正在讨论的补丁(https://lkml.org/lkml/2007/3/19/100)以添加 ru_inblock 和 ru_oublock:

    As TASK_IO_ACCOUNTING currently counts bytes, we approximate blocks
    count doing : nr_blocks = nr_bytes / 512
    

    检查当前内核源代码(https://github.com/spotify/linux/blob/master/include/linux/task_io_accounting_ops.h)显示:

    /*
     * We approximate number of blocks, because we account bytes only.
     * A 'block' is 512 bytes
     */
    static inline unsigned long task_io_get_inblock(const struct task_struct *p)
    {
        return p->ioac.read_bytes >> 9;
    }
    

    和

    /*
     * We approximate number of blocks, because we account bytes only.
     * A 'block' is 512 bytes
     */
    static inline unsigned long task_io_get_oublock(const struct task_struct *p)
    {
        return p->ioac.write_bytes >> 9;
    }
    

    简而言之,是的,每个块大约有 512 个字节。

    • 4
  2. Janne Pikkarainen
    2019-01-30T02:47:11+08:002019-01-30T02:47:11+08:00

    我猜“文件系统输入/输出”是指块大小,所以如果底层文件系统已被格式化为 512 字节块,它会返回那个,如果有别的,那么就是那个。

    但这只是一个猜测。

    • 2

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve