As I understand it, when you mmap a file you are basically mapping the pages from the page cache for that file directly into your process, and when you use O_DIRECT you are bypassing the page cache. Does it ever make sense to use the two together? If my understanding is right how would it even work? mmap seems to
Tag: io
Linux total disk I/O from already running process
I’m working on a performance tool and I’m interested in the total disk I/O i single process have done since it started. I have the porcess PID and i can easily get the current I/O rate with tools like iotop or sar, but not the total I/O. Is this even logged in Linux and is there a way to get
How to grep a string in a program?
Description: The str_buf_to_grep is given in any way, which might be the content of a text file, and might be very long and complex, even contains special characters, such as |, “, etc. I want to use the grep command to find matched lines, and the patterns might be very complex. How should I implement it? Answer Use popen: The
How does C distinguish between a byte long character and a 2 byte long character?
I have this sample code: First run: Well I think this is all expected as p is 1 byte long character defined in ASCII and I am reading 3 bytes. (2 p’s and Line break) In the terminal, again I see 2 characters. Now let’s try with a character that is 2 bytes long: What I do not understand is,
How can I redirect the output of a process file write?
I have a legacy app running that sends its output to log files. Rather than tail and manage those log files, I want to capture the output before it hits the disk and send it off elsewhere on the network (using syslog, or fluentd, or logstash, etc.). Is there any way I can capture the output without changing the application
I read more than I write in file
I have a file, partitioned in fixed sized blocks. I am copying a test_file.txt into the 3rd block of the file. I read and copied 18 bytes. Then I am trying to copy from the file that very same .txt file I just imported to a newly created .txt, but I am writing 256 bytes to the new file. Moreover,
Reliable writes in linux
My requirement is to write a never ending stream of incoming variable sized binary messages to the file system. Messages of average size 2KB arrive at 1000 messages/sec. So in an hour, total number of messages would be 3600*1000*2 = 6.8 GB. The main purpose of the messages is following 1. Archive them for auditing purposes 2. Provide a search