Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multithreaded file access

I am writing a hex editor program and I was thinking about when a user tries to open a very large file (3GB+). I wouldn't want the user to sit around all day for the whole file to load when it already has some data loaded.

So here is my question, would it be possible to have multiple threads read the file (not write) simultaneously, at different places, and then then once a certain threshold of data has been read by 1, that thread displays its data while the others continue to read? Would that offer me a performance improvement? Or would memory bandwidths reduce any speed gain I could get from using multiple threads?

like image 364
samoz Avatar asked Dec 17 '22 07:12

samoz


1 Answers

For a hex-editor, there is no nead to read the whole file into memory. The user can only view or modify the data but without inserting or deleting.

You can simply use memory mapped files. The data will be automatically read when accessed and only the chunk displayed will be read. This provide fast scrolling and jumping to any location in the file.

like image 153
bill Avatar answered Dec 19 '22 21:12

bill