Tuesday, April 23, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1912  / 2 Years ago, wed, august 17, 2022, 8:12:46

I've downloaded a lot of torrent files and while I'm seeding them, I've noticed that very often when I start the browser it's slow and the hard disk activity indicator is on. Usually when I start a program it gets cached in RAM and starting it again is very quick, and I have 3 GB of RAM so usually it stays cached nearly forever. But when my torrent client is seeding it seems that after an hour programs that I ran are no longer cached in RAM.



I was thinking maybe it's because of the disk reads which the torrent client performs are cached and fill up RAM eventually. But I don't think they need to be, as they are read only once and are unlikely to be read again soon.



So my questions are - is this the way I think, and if so is it possible in principle to prevent the disk reads from being cached? I can try to edit the source code of the program.


More From » ram

 Answers
7

It will depend exactly which torrent program you're using. Some of them might behave in different ways.



But yes, it is possible to bypass system cache since this is a common problem.



If you're comfortable editing source (perhaps this should be on another StackExchange..) find where the torrent program opens the file from disk. Most likely an open() call. If it is fdopen() then it's using stdlib and I'm not sure stdlib supports direct i/o.



This system call takes up to three arguments, the first one is the filename, the second are flags, the third is an optional file create mask. The flags will probably be something like O_RDWR at the moment. The flag for "don't use system cache" is O_DIRECT, and you combine flags by separating them with |.



So the result of the flags argument in this case would be O_RDWR | O_DIRECT. Just add the new flag on.



For more information, see



man 2 open

[#41896] Friday, August 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
girdleas

Total Points: 1
Total Questions: 112
Total Answers: 114

Location: Lesotho
Member since Wed, Jun 2, 2021
3 Years ago
girdleas questions
;