| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
procfile is a library for reading text data files (i.e /proc files) in the fastest possible way.
The library automatically adapts (through the iterations) its memory so that each file is read with single read() call.
Then the library splits the file into words, using the supplied separators. The library also supported quoted words (i.e. strings within of which the separators are ignored).
Initially the caller:
For each iteration, the caller:
calls procfile_readall() to read updated contents. This call also rewinds (lseek() to 0) before reading it.
For every file, a BUFFER is used that is automatically adjusted to fit the entire file contents of the file. So the file is read with a single read() call (providing atomicity / consistency when the data are read from the kernel).
Once the data are read, 2 arrays of pointers are updated:
This is highly optimized. Both arrays are automatically adjusted to fit all contents and are updated in a single pass on the data.
The library provides a number of macros:
When the caller exits:
To achieve this kind of performance, the library tries to work in batches so that the code and the data are inside the processor's caches.
This library is extensively used in Netdata and its plugins.
| Back | FazBrowse Home | New Git URL |