Closed chrfranke closed 2 months ago
Sounds like a good idea. So if I understand this:
Additional features: 1) Make write/read size user selectable 2) Make seek position randomized (with no over-lapping between processes) 3) Make number of child processes user selectable. 4) Use pthreads instead of fork()
How a new stressor named pseekio to do this? (or any better name if you can think of one)
Sounds good. Other possible name: preadwrite ?
Written blocks could possibly be filled with (instance_number, file_offset, write_count)
in some encoding. This allows to check that R/W ops are atomic. Instance N could seek with SEEK_CUR
and then check the expected position to ensure that the previous seek position was not moved by other instances.
Another possible enhancement: Use pthreads in each fork()ed process.
preadwrite is kind of ok apart from the fact that the stressor does pwrite and then pread and the name extra options make the options really quite long in name.
I've got an initial implementation done now, but I'm now thinking of mixing the processes with 50% pthreads and 50% forked child processes. If a system does not support pthread it will do 100% forked child processes.
Thanks! Looks good so far and reveals a subtle bug on Cygwin.
It would be useful if the --verbose
mode would provide information about processes and threads actually started by each stressor instance (also applies to other stressors with more than one process/thread per instance).
BTW, there is a useless assigment proc->pthread_ret = -1;
in line 303.
The
pread*()/pwrite*()
family of functions are the only way to do parallel random accesses on the same, dup()ed or inherited file descriptor without additional locking. This leads to the following idea (sorry if I missed that something similar is already present):Create a file and inherit its fd to multiple fork()ed processes. Each process repeatedly writes modified process specific data to a private file section and then reads and checks the other sections. One process does this with
lseek()/read()/write()
, all others do this withpread()/pwrite()
.Could also be done with multiple threads using the same file descriptor.
Here a related comment in the source of the Cygwin POSIX emulation layer: https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/fhandler/disk_file.cc;h=f4c21d3#l1736