arter97 / exfat-linux

EOL exFAT filesystem module for Linux kernel. Everyone should be using https://github.com/namjaejeon/linux-exfat-oot instead.
Other
262 stars 61 forks source link

Direct IO write speed is much slower than exfat-nofuse #29

Open happyzlw opened 3 years ago

happyzlw commented 3 years ago

Exfat-linux cache IO has excellent write speed compared to Exfat-nofuse, thanks to your optimization . But direct IO is slow, with only half the write speed compared to exfat-nofuse.Exfat-linux would be perfect if this direct-IO slow problem were solved.

arter97 commented 3 years ago

Did you confirm that exfat-nofuse is handling direct I/O properly?

See if free memory from /proc/meminfo doesn't change on DIO writes.

happyzlw commented 3 years ago

Did you confirm that exfat-nofuse is handling direct I/O properly?

----yes,the results of my tests on my storage media are(sequential I/O write):

1.direct-io 320MB/s (exfat-nofuse), 160MB/s (exfat-linux) 2.cache-io 260MB/s (exfat-nofuse) 285MB/s (exfat-linux) The content of the file is ok, direct-io and cache-io.

See if free memory from /proc/meminfo doesn't change on DIO writes

-----Free Memory from /proc/meminfo is basically unchanged on DIO writes.

arter97 commented 3 years ago

That number looks wrong. Wrong enough to suspect something's wrong with exfat-nofuse's DIO.

Can you count the total wall time on DIO write and umount on both nofuse and this?

happyzlw commented 3 years ago

That number looks wrong. Wrong enough to suspect something's wrong with exfat-nofuse's DIO. There are no errors in the test data, which are all based on page align buffer, with a single write of 4MB.This was tested on an embedded ARM platform. Can you count the total wall time on DIO write and umount on both nofuse and this? I'm sorry, but I don't quite understand your question

Write speed test code: `static double diffTime(struct timeval stru_stop, struct timeval stru_start) { return ( (double)((1000000.0stru_stop.tv_sec + stru_stop.tv_usec) - (1000000.0stru_start.tv_sec + stru_start.tv_usec)) )/1000000.0; }

int main(void) { int fd = -1, i, j, count = 100; int per_count = 8; struct timeval stru_start; struct timeval stru_stop; double write_time= 0; int block_byte = 410241024; int total_size = 4per_count; char write_buf = NULL; posix_memalign((void**)&write_buf, getpagesize(), block_byte);//malloc(block_byte); for(i = 0; i < block_byte; i++) { write_buf[i] =i; } fd = open("/tmp/mnt/usb/test.bin", O_CREAT|O_DIRECT|O_RDWR|O_TRUNC); if(fd == -1) { printf("open file error\n"); return -1; } for(i = 0; i < count; i++) { printf("speed test [%d]\n", i); gettimeofday(&stru_start, NULL); for(j = 0; j < per_count; j++) { if(write(fd, write_buf, block_byte) < 0) { printf(" write error\n"); return -1; } } fsync(fd); gettimeofday(&stru_stop, NULL); write_time= diffTime(stru_stop, stru_start); printf("all time diff: %.3f s\n\n", write_time); printf("data %d M %.3f M/s \n\n", total_size, total_size/write_time); } close(fd); free(write_buf); }`

happyzlw commented 3 years ago

If you open an existing file (size 4GB, file open by O_CREAT|O_DIRECT|O_RDWR), test the write speed, DIO 343MB/S on exfat-linux, it is very good. But If you create a new file, or open with O_TRUNC, the DIO write speed is 160MB/s on exfat-linux.