algorithm - 为什么 Unix block 大小会随着内存大小的增加而增加?

标签 algorithm unix memory time-complexity space-complexity

我正在分析具有

的二进制数据
  • 当事件数量增加时增加Unix block 大小(一个从stat > Blocks得到)如下图
  • 但事件之间的字节距离保持不变
  • 我注意到文件的其他字段发生了一些变化,这可能解释了 Unix block 大小的增加

enter image description here

unix block 大小是一个动态度量。 我感兴趣的是为什么它在某些系统中随着更大的内存单元而增加。 我有一个想法,它应该是恒定的。 我使用不同的环境来提供 stat 输出:

  • Debian Linux 8.1 及其默认 stat
  • 带有 Xcode 6 的 OSX 10.8.5 及其默认 stat

Greybeard 的评论可能对积木行为有答案:

The stat (1) command used to be a thin CLI to the stat (2) system call, which used to transfer relevant parts of a file's inode. Pretty early on, the meaning of the st_blksize member of the C struct returned by stat (2) was changed to "preferred" blocksize for efficient file system I/O, which carries well to file systems with mixed block sizes or non-block oriented allocation.

如何分别测量情况(1)和(2)中的 block 大小?

为什么 Unix 的 block 大小会随着内存大小的增加而增加?

最佳答案

“统计 block ”不是 block 大小。它是文件包含的 block 数。很明显, block 的数量与大小成正比。对于大多数文件系统(如果不是全部), block 的大小是恒定的。

关于algorithm - 为什么 Unix block 大小会随着内存大小的增加而增加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32123914/

相关文章:

将自删除推回 vector 时 C++ 崩溃

c - Julia 用实数设置计算

algorithm - 为什么 BFS 的复杂度是 O(V+E) 而不是 O(V*E)?

c - 为什么 Valgrind 在这个哈希表测试用例中发现错误?

c - 使用共享内存运行程序时出现问题;有时会出现段错误; shmmax和shmall有关系吗?

unix - 如何仅从 ls -al 正确 grep 文件名

algorithm - 创建没有一个相交元素的组合

c - 如何找到固定 n 的前 r 个二项式系数之和?

linux - root 是否会覆盖在 unix 中设置为目录的只读权限(甚至是 root 权限)?

php - 将 Unix 时间转换为日期和时间,无需使用任何库或预定义的帮助程序