It is often said that a file is divided into many small files. If you need to "open file handle-write data-Close file handle" after each judgment ", it takes a lot of time to repeatedly open or close the file handle.
The process is often in the "S" sleep state.
If multiple files are opened at the same time and the file to be written is determined, the CPU wait time can be reduced.
For my $ I (0 .. 99)
{
$ O = "out". $ I;
Open $ O, "> test. $ I" or die $ !;
Print $ o "test ";
Close $ O;
}
Number of files allowed to be opened simultaneously in Linux:
/Proc/sys/fs/file-max
Appendix:
How does one modify the maximum number of file descriptors that can be opened simultaneously in the Linux kernel by default?
Source code file found File-max <kernel-path>;/fs/file. c Inode-Nr <kernel-path>;/fs/innode. cIf the system is not a streamlined kernel, use the following methods to modify it: Ulimit-n <number of files that can be opened at the same time>; sets the maximum number of files that can be opened at the same time (max open files) # Echo "65536">;/proc/sys/fs/file-Max # Applicable to 2.2 and 2.4 kernels # Echo "131072">;/proc/sys/fs/inode-Max # Applicable only to kernel 2.2 Or Add the following content to/etc/sysctl. conf to make permanent changes: |