Skip to content

Commit 4724316

Browse files
committed
adaptived: README: Update flow chart and examples
Add a few real-world examples. Update the flow chart to fix rendering issues. Signed-off-by: Tom Hromatka <[email protected]>
1 parent 67e67e7 commit 4724316

File tree

3 files changed

+122
-10
lines changed

3 files changed

+122
-10
lines changed

adaptived/README.md

Lines changed: 122 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
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.
36

47
Adaptived has several built-in causes and effects. When using only the built-in
58
causes and effects, adaptived can be invoked directly by calling the adaptived
@@ -24,16 +27,16 @@ Adaptived uses the following terminology:
2427
Baring an error, each effect will run when the associated causes are
2528
triggered.
2629
* 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.
2932

3033
## Architecture
3134

3235
Adaptived's main processing loop operates as shown in the flow chart below:
3336

3437
![Adaptived flow chart](./doc/examples/flow-chart.png)
3538

36-
## Simple Use Case - Built-In Causes and Effects
39+
## Getting Started
3740

3841
If a user only wants to utilize the built-in causes and effects in adaptived,
3942
then they can invoke the daemon directly.
@@ -48,13 +51,34 @@ The above command will start the adaptived daemon. It will employ the rules
4851
outlined in the provided configuration file, and the main adaptived loop will run
4952
every 3 seconds.
5053

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
5255
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
5659
run and output the aforementioned message.
5760

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+
5882
## Advanced Use Case - Custom Causes and/or Effects
5983

6084
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,
6892
[003-register_plugin_cause.c](./tests/ftests/003-register_plugin_cause.c),
6993
is a good starting point.
7094

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+
71183
## Additional Resources
72184

73185
* [List of Built-In Causes](./doc/internal/list-of-built-in-causes.md)
@@ -111,7 +223,7 @@ applications:
111223

112224
However, if you are building the library from sources retrieved from the source
113225
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
115227
configuration options.
116228

117229
## Testing the Library

adaptived/doc/examples/flow-chart.odp

10.7 KB
Binary file not shown.

adaptived/doc/examples/flow-chart.png

2.63 KB
Loading

0 commit comments

Comments
 (0)