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