summaryrefslogtreecommitdiffstats
path: root/libnetdata/procfile
diff options
context:
space:
mode:
authorPromise Akpan <akpanpromise@hotmail.com>2019-08-15 12:06:39 +0100
committerChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-08-15 13:06:39 +0200
commitf5006d51e8caf9148d393eb68d53dc9fcd28b7b6 (patch)
tree03b757236d6b45e46813a4a875c77dc775e5f896 /libnetdata/procfile
parent69172fd57472df75d877f43de2dcc693c48ab5c0 (diff)
Fix Markdown Lint warnings (#6664)
* make remark access all directories * detailed fix after autofix by remark lint * cross check autofix for this set of files * crosscheck more files * crosschecking and small fixes * crosscheck autofixed md files
Diffstat (limited to 'libnetdata/procfile')
-rw-r--r--libnetdata/procfile/README.md47
1 files changed, 23 insertions, 24 deletions
diff --git a/libnetdata/procfile/README.md b/libnetdata/procfile/README.md
index de989ccb3d..7487e6c634 100644
--- a/libnetdata/procfile/README.md
+++ b/libnetdata/procfile/README.md
@@ -1,4 +1,3 @@
-
# PROCFILE
procfile is a library for reading text data files (i.e `/proc` files) in the fastest possible way.
@@ -15,49 +14,49 @@ The library also supported quoted words (i.e. strings within of which the separa
Initially the caller:
-- calls `procfile_open()` to open the file and allocate the structures needed.
+- calls `procfile_open()` to open the file and allocate the structures needed.
### Iterations
For each iteration, the caller:
-- calls `procfile_readall()` to read updated contents.
- This call also rewinds (`lseek()` to 0) before reading it.
+- calls `procfile_readall()` to read updated contents.
+ This call also rewinds (`lseek()` to 0) before reading it.
+
+ For every file, a [BUFFER](../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:
- For every file, a [BUFFER](../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).
+ - a `words` array, pointing to each word in the data read
+ - a `lines` array, pointing to the first word for each line
- 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.
- - a `words` array, pointing to each word in the data read
- - a `lines` array, pointing to the first word for each line
+ The library provides a number of macros:
- 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:
-
- - `procfile_lines()` returns the # of lines read
- - `procfile_linewords()` returns the # of words in the given line
- - `procfile_word()` returns a pointer the given word #
- - `procfile_line()` returns a pointer to the first word of the given line #
- - `procfile_lineword()` returns a pointer to the given word # of the given line #
+ - `procfile_lines()` returns the # of lines read
+ - `procfile_linewords()` returns the # of words in the given line
+ - `procfile_word()` returns a pointer the given word #
+ - `procfile_line()` returns a pointer to the first word of the given line #
+ - `procfile_lineword()` returns a pointer to the given word # of the given line #
### Cleanup
When the caller exits:
-- calls `procfile_free()` to close the file and free all memory used.
+- calls `procfile_free()` to close the file and free all memory used.
### Performance
-- a **raspberry Pi 1** (the oldest single core one) can process 5.000+ `/proc` files per second.
-- a **J1900 Celeron** processor can process 23.000+ `/proc` files per second per core.
+- a **raspberry Pi 1** (the oldest single core one) can process 5.000+ `/proc` files per second.
+- a **J1900 Celeron** processor can process 23.000+ `/proc` files per second per core.
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.
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Flibnetdata%2Fprocfile%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Flibnetdata%2Fprocfile%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)