Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Unix block size increase with bigger memory size?

I am profiling binary data which has

  • increasing Unix block size (one got from stat > Blocks) when the number of events are increased as in the following figure
  • but the byte distance between events stay constant
  • I have noticed some changes in other fields of the file which may explain the increasing Unix block size

enter image description here

The unix block size is a dynamic measure. I am interested in why it is increasing with bigger memory units in some systems. I have had an idea that it should be constant. I used different environments to provide the stat output:

  • Debian Linux 8.1 with its default stat
  • OSX 10.8.5 with Xcode 6 and its default stat

Greybeard's comment may have the answer to the blocks behaviour:

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.

How can you measure the block size in case (1) and (2) separately?

Why can the Unix block size increase with bigger memory size?

like image 809
Léo Léopold Hertz 준영 Avatar asked Aug 20 '15 16:08

Léo Léopold Hertz 준영


People also ask

What is the size of block of Unix?

The logical block size is the size of the blocks that the UNIX kernel uses to read or write files. The logical block size is usually different from the physical block size. The physical block size is usually 512 bytes, which is the size of the smallest block that the disk controller can read or write.

What is the block size of storage in Linux environment?

All Linux file systems have 4kb block size.

Does dd block size matter?

The default block size for dd is 512. The only effect leaving it alone is likely to have in most modern circumstances is to make the copying process slower. Save this answer.

What is block size in storage?

A block is the largest contiguous amount of disk space that can be allocated to a file and is therefore the largest amount of data that can be accessed in a single I/O operation. A subblock is the smallest unit of contiguous disk space that can be allocated.


1 Answers

"Stat blocks" is not a block size. It is number of blocks the file consists of. It is obvious that number of blocks is proportional to size. Size of block is constant for most file systems (if not all).

like image 159
Konstantin Svintsov Avatar answered Nov 10 '22 18:11

Konstantin Svintsov