You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to https://github.com/shichao-an/notes/blob/master/docs/lkd/ch14.md : I'm not sure whether that fits as book comments, but since it was probably the best introduction in the matter that I could quickly find online, I want to share my two cents, that one may or may not find useful:
Suppose we need to find out what's the optimal buffer size for reading from a device. Or have special needs -- e.g. want to tune a ZFS filesystem recordsize for a custom on-disk database -- may be even with enabled deduplication, what will make our needs really special.
So we wonder how the system reads and writes data from/to the device. These i/o buffers would be directly related to sector or block sizes.
As for device block sizes -- they, of course, first come from the device itself ; look at
to https://github.com/shichao-an/notes/blob/master/docs/lkd/ch14.md :
I'm not sure whether that fits as book comments, but since it was probably the best introduction in the matter that I could quickly find online, I want to share my two cents, that one may or may not find useful:
Suppose we need to find out what's the optimal buffer size for reading from a device. Or have special needs -- e.g. want to tune a ZFS filesystem recordsize for a custom on-disk database -- may be even with enabled deduplication, what will make our needs really special.
So we wonder how the system reads and writes data from/to the device. These i/o buffers would be directly related to sector or block sizes.
As for device block sizes -- they, of course, first come from the device itself ; look at
That would be the same as
smartctl
orhdparm
would tell us:"Physical" and "logical" here would differ e.g. for Advanced Format disks ( and we'll be more interested in
physical_block_size
, if it's different ).Next, there's something reported by
man 2 stat
(struct stat -> st_blksize
) :This essentially comes from the filesystem. ( In short, fs/stat.c shows that
st_blksize
comes from the inode, the inode gets it from the superblock, and the superblock normally has it as a power of two capped at PAGE_SIZE, i.e. the memory page size. )So basically this boils down to a memory page size. Good to know.
PS. This is for example how
cat
determines the optimal buffer size :-- and it does not perform that bad at all:
The text was updated successfully, but these errors were encountered: