@@ -24,16 +24,16 @@ Adaptived uses the following terminology:
24
24
Baring an error, each effect will run when the associated causes are
25
25
triggered.
26
26
* Rule - A rule is one or more causes combined with one or more effects. When
27
- all of the causes in the rule are triggered, then the effects will be
28
- executed. A adaptived configuration file can contain multiple rules.
27
+ all of the causes in the rule are triggered, then the effect(s) will be
28
+ executed. An adaptived configuration file can contain multiple rules.
29
29
30
30
## Architecture
31
31
32
32
Adaptived's main processing loop operates as shown in the flow chart below:
33
33
34
34
![ Adaptived flow chart] ( ./doc/examples/flow-chart.png )
35
35
36
- ## Simple Use Case - Built-In Causes and Effects
36
+ ## Getting Started
37
37
38
38
If a user only wants to utilize the built-in causes and effects in adaptived,
39
39
then they can invoke the daemon directly.
@@ -48,13 +48,34 @@ The above command will start the adaptived daemon. It will employ the rules
48
48
outlined in the provided configuration file, and the main adaptived loop will run
49
49
every 3 seconds.
50
50
51
- Given the rule in this example, adaptived will print " It's 5 o'clock here :)" when
51
+ Given the rule in this example, adaptived will print ` It's 5 o'clock here :) ` when
52
52
the time is after 5 pm and it's a weekday. It will print that message until
53
- midnight, and then the time_of_day cause will fail . Since no maximum number of
54
- loops was provided in this example, adaptived will continue running until it is
55
- killed. Once it's after 5 pm and a weekday, then the print effect will again
53
+ midnight, and then the ` time_of_day ` cause will no longer trigger . Since no maximum
54
+ number of loops was provided in this example, adaptived will continue running until
55
+ it is killed. Once it's after 5 pm and a weekday, then the print effect will again
56
56
run and output the aforementioned message.
57
57
58
+ ## Real-World Use Cases
59
+
60
+ * Given two cgroups, high-priority and low-priority, kill processes in the
61
+ low-priority cgroup when there is PSI pressure on the high-priority cgroup
62
+ [[ 1]] ( https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/examples/kill-lowpriority.json )
63
+ * Given two cgroups, high-priority and low-priority, reduce the cpu.weight
64
+ of the low-priority cgroup when there is PSI pressure on the high-priority
65
+ cgroup. Conversely, when there is very little pressure on the high-priority
66
+ cgroup, increase the cpu.weight of the low-priority cgroup
67
+ [[ 2]] ( https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/examples/adjust-weight.json )
68
+ * Adjust a cgroup's soft memory limit (memory.high) to determine the minimum
69
+ memory requirements of an application. This value could be used to
70
+ populate that application's memory.low cgroup setting
71
+ [[ 3]] ( https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/examples/determine-memorylow.json )
72
+ * When an anomalous event occurs, save critical logs off for later offline
73
+ evaluation and troubleshooting
74
+ [[ 4]] ( https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/examples/topmem-savelogs.json )
75
+ * When the system's MemFree field falls below a threshold, send a signal to a
76
+ monitoring process
77
+ [[ 5]] ( https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/examples/lowmemfree-sendsignal.json )
78
+
58
79
## Advanced Use Case - Custom Causes and/or Effects
59
80
60
81
Adaptived allows for users to create their own custom causes and effects. (Note
@@ -68,6 +89,94 @@ library and its C APIs. The automated test,
68
89
[ 003-register_plugin_cause.c] ( ./tests/ftests/003-register_plugin_cause.c ) ,
69
90
is a good starting point.
70
91
92
+ ## Schema
93
+
94
+ An example adaptived JSON configuration file is attached below. Note that the
95
+ ` comment ` fields are for illustrative purposes and are not required. (In fact,
96
+ adaptived will ignore fields that aren't part of its schema. As outlined
97
+ below, these ignored fields could be a way to document the configuration
98
+ file.)
99
+
100
+ ```
101
+ {
102
+ "comment1": "adaptived configuration files consist of one or more rules.",
103
+ "comment2": "The rules are processed independent of each other,",
104
+ "comment3": "therefore ensure that one rule doesn't adversely affect another rule.",
105
+ "rules": [
106
+ {
107
+ "name": "We recommend a short but descriptive rule name",
108
+ "comment1": "The rule name must be unique as the name is used as the built-in identifier",
109
+ "comment2": "Also, the rule name is displayed in debug logs, so a short-but-descriptive name is very helpful in debugging",
110
+ "description": "Optional but helpful for further describing the rule.",
111
+
112
+ "causes comment1": "A rule consists of one of more causes.",
113
+ "causes comment2": "Every cause is run every time the main adaptived processing loop runs.",
114
+ "causes comment3": "Every cause must trigger for the effect(s) to be run.",
115
+ "currently-supported causes": "https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/internal/list-of-built-in-causes.md",
116
+ "causes": [
117
+ {
118
+ "name": "cause 1 name",
119
+ "args": {
120
+ "comment1": "Each cause has its own set of args applicable to that cause.",
121
+ "comment2": "See the list of built-in causes for the args supported by each cause"
122
+ }
123
+ },
124
+ {
125
+ "name": "cause 2 name",
126
+ "comment1": "Even if cause 1 does not trigger, this cause will be evaluated every time the adaptived processing loop runs.",
127
+ "comment2": "This is critical so that averages, trends, etc. can be properly computed.",
128
+ "args": {}
129
+ }
130
+ ],
131
+
132
+ "effects comment1": "A rule consists of one or more effects.",
133
+ "effects comment2": "The effect(s) will only be run if every cause in this rule triggers.",
134
+ "currently-supported effects": "https://github.com/oracle/adaptivemm/blob/master/adaptived/doc/internal/list-of-built-in-effects.md",
135
+ "effects": [
136
+ {
137
+ "name": "effect 1 name",
138
+ "args": {
139
+ "comment1": "Just like with the causes, each effect has its own set of args applicable to that effect.",
140
+ "comment2": "See the list of built-in effects for the args supported by each effect."
141
+ }
142
+ },
143
+ {
144
+ "name": "effect 2 name",
145
+ "args": {}
146
+ }
147
+ ]
148
+ },
149
+
150
+ {
151
+ "name": "When MemFree falls below 2 GB, send SIGALRM (signal 14) to the monitoring program",
152
+ "causes": [
153
+ {
154
+ "name": "meminfo",
155
+ "args": {
156
+ "field": "MemFree",
157
+ "threshold": "2G",
158
+ "operator": "lessthan"
159
+ }
160
+ }
161
+ ],
162
+ "effects": [
163
+ {
164
+ "name": "signal",
165
+ "args": {
166
+ "proc_names": [
167
+ {
168
+ "name": "monitor_program"
169
+ }
170
+ ],
171
+ "signal": 14
172
+ }
173
+ }
174
+ ]
175
+ }
176
+ ]
177
+ }
178
+ ```
179
+
71
180
## Additional Resources
72
181
73
182
* [ List of Built-In Causes] ( ./doc/internal/list-of-built-in-causes.md )
@@ -111,7 +220,7 @@ applications:
111
220
112
221
However, if you are building the library from sources retrieved from the source
113
222
repository you may need to run the autogen.sh script before running configure.
114
- In both cases, running " ./configure -h" will display a list of build-time
223
+ In both cases, running ` ./configure -h ` will display a list of build-time
115
224
configuration options.
116
225
117
226
## Testing the Library
0 commit comments