I need to read a single file using multiple threads in Linux. There are only read operations and no need to write. Reading a file does not need to read the entire file every time. It must read one or more parts of the file each time. I stored the offset of each part in advance. The file is too large to fit into main memory.
So, for example, many users want to read such a file. I use a thread or process to read a file to respond to user requests. What will happen on Linux? Will all read operations be queued? And will the OS finish reading the file one by one? Is it possible to improve the performance of such operations?
I am trying to implement a simple inverted index used when searching for information. I put the dictionary into memory and publish lists in files. Each file contains an index segment. In the dictionary, I can store something like an offset to indicate the position of the word posting list. When 100 users want to find something in one second, they send different requests. Therefore, each reading will read a different part of the file.
If the file is too large to fit in the system memory and you have many threads that need to read the entire file, there is a good chance that your application will be limited by disk I / O ... no matter how you read the file, and how no matter how smart the OS is.
, . , , . , , . , , , . ( , , . , .)
. , .
EDIT: , . ( !), . , @Jon Skeet . , , /. :
. , Witten ..
- .. , - , . :)
, , , , .
, . , . (.. ) . ( , , , ), , . ( , , , ). , , . ( ) , .
, . , ? ? , ? . , , RAM, , , , . , , ? , mmap() , , . , , . , .
mmap()
, - , !
, ?
/, mmap(), () , . 32- , "- 4 , , , 2 "; 64- , , .
, mmap(); .
(Linux .) , , ? , . , , . , , , .
, , ( ), : (RAID 10). , , .
,
, ( )... , ,
Source: https://habr.com/ru/post/1718439/More articles:Best web server performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1718435/jquery-droppable-out-event-fails-to-trigger&usg=ALkJrhj04db8WxhFbwNR2ion20a8BNZipgAir Flex loads maximum URLRequest at the same time - flexHow can I interact with the Perl debugger API? - debuggingMouse control in linux - c ++How to debug ISAPI using Visual Studio - visual-studiojqGrid stuck on loading? - jqueryWhy is WindowsError when deleting a temporary file? - pythonProgramming Contests and Job Search - computer-visionVBA - показать время с точностью менее секунды - vbaAll Articles