Linux I / O performance

File A is in a directory in which there are 10,000 files, and file B is in a directory in which there are 10 files. Will reading / writing a file be slower than file B? Will another log file system be affected?

+4
source share
3 answers

No.

Browse the directory and open the file will be slower (regardless of how noticeable in practice depends on the file system). The input / output in the file is exactly the same.

EDIT:
To clarify, the "file" in the directory is not really a file, but a link (a "hard link", as opposed to a symbolic link), which is just a kind of name with some metadata, but otherwise not related, d consider "file". This is also the historical reason why file deletion is done using syscall unlink , rather than through a hypothetical deletefile call. unlink removes the link, and if it was the last link (but only then!), the file.

It is natural that one file has a hundred links in different directories, and it is completely legal to open the file, and then move it to another location or even turn it off (while it remains open!). This does not affect your ability to read / write in the file descriptor, even if the file (as far as you know) does not even exist.

+5
source

In the general case, as soon as the file has been opened and you have a descriptor, the performance of access to this file will be the same regardless of how many other files are in the same directory. You may find a slight difference in the time it takes to open the file, since the OS will look for the file name in the directory.

+1
source

Logging is aimed at reducing the recovery time from file system failures, IMHO, this will not affect the speed of reading / writing files. Ext2 logging

0
source

All Articles