diff options
author | Andrew Cady <d@cryptonomic.net> | 2022-11-29 12:31:17 -0500 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2022-11-29 12:31:17 -0500 |
commit | 07d4f9c7df8d226ce77b9cf8e81432530f8a1cb4 (patch) | |
tree | 5d53b283632b201eeceef7904b0bdab2aad8fbec | |
parent | 60c4d3c09fd1a03661306104b37ac73e88489080 (diff) |
rename ioslay-mgr.sh; test write ops
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.txt | 2 | ||||
-rwxr-xr-x | firestart | 31 | ||||
-rwxr-xr-x | src/firefox-io-slayer (renamed from src/ioslay-mgr.sh) | 0 |
4 files changed, 28 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | BINDIR = /usr/local/bin | 1 | BINDIR = /usr/local/bin |
2 | BINARIES = firestart firestartx $(addprefix src/,sliceweasel.lib.sh ioslay-mgr.sh ioslay-firefox) | 2 | BINARIES = firestart firestartx $(addprefix src/,sliceweasel.lib.sh firefox-io-slayer ioslay-firefox) |
3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo | 3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo |
4 | 4 | ||
5 | .PHONY: install install-bin | 5 | .PHONY: install install-bin |
@@ -14,7 +14,7 @@ Then you can use the two commands: | |||
14 | firestartx - start Firefox in a CGroup and X server sandbox (recommended) | 14 | firestartx - start Firefox in a CGroup and X server sandbox (recommended) |
15 | 15 | ||
16 | Within the `firefox` systemd service, a background service called `ioslay` will | 16 | Within the `firefox` systemd service, a background service called `ioslay` will |
17 | be started by `ioslay-mgr.sh`. | 17 | be started by `firefox-io-slayer`. |
18 | 18 | ||
19 | The launching of Firefox through either of these commands launches a watchdog | 19 | The launching of Firefox through either of these commands launches a watchdog |
20 | process that kills Firefox processes when they are spinning the disk. | 20 | process that kills Firefox processes when they are spinning the disk. |
@@ -1,20 +1,41 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } | 3 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } |
4 | 4 | ||
5 | # Test DEVICE WRITE OPS BY WRITEOPS | ||
6 | test_write_ops() | ||
7 | { | ||
8 | if ! [ -e "$1" ] | ||
9 | then | ||
10 | mkdir -p "$(dirname "$1")" | ||
11 | sync | ||
12 | begin=$(date +%s.%N) | ||
13 | dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=300 | ||
14 | sync | ||
15 | end=$(date +%s.%N) | ||
16 | rm "$DIR"/urandom.out | ||
17 | bc -q > "$1" <<< "scale=5; seconds=$end - $begin; 300*1000*1000/seconds" | ||
18 | fi | ||
19 | cat "$1" | ||
20 | } | ||
21 | |||
5 | CMD=firefox | 22 | CMD=firefox |
6 | UNIT=$CMD | 23 | UNIT=$CMD |
7 | DIR=~/.mozilla | 24 | DIR=~/.mozilla |
8 | MEMORY_MAX=50% | 25 | MEMORY_MAX=50% |
9 | READ_OPS=1G | 26 | READ_OPS=1G |
10 | WRITE_OPS=$READ_OPS | 27 | WRITE_OPS=$READ_OPS |
11 | CONFDIR=$HOME/.config/firestart/conf | 28 | CONFDIR=$HOME/.config/firestart |
12 | 29 | ||
13 | if [ -e "$CONFDIR" ] | 30 | if [ -e "$CONFDIR"/conf ] |
14 | then | 31 | then |
15 | . "$CONFDIR" | 32 | . "$CONFDIR"/conf |
16 | fi | 33 | fi |
17 | 34 | ||
35 | WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat) | ||
36 | WRITE_OPS=${WRITE_OPS%.*} | ||
37 | READ_OPS=$WRITE_OPS | ||
38 | |||
18 | if systemctl --user is-active "$UNIT" >/dev/null | 39 | if systemctl --user is-active "$UNIT" >/dev/null |
19 | then | 40 | then |
20 | exec "$CMD" "$@" # Asks existing firefox to open a new window. | 41 | exec "$CMD" "$@" # Asks existing firefox to open a new window. |
@@ -27,7 +48,7 @@ fi | |||
27 | DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n)) | 48 | DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n)) |
28 | [ "$DEV" ] || die "could not determine backing device for $DIR" | 49 | [ "$DEV" ] || die "could not determine backing device for $DIR" |
29 | 50 | ||
30 | ioslay-mgr.sh launch-unit | 51 | firefox-io-slayer launch-unit |
31 | 52 | ||
32 | systemctl --user reset-failed "$UNIT" 2>/dev/null | 53 | systemctl --user reset-failed "$UNIT" 2>/dev/null |
33 | systemd-run --user \ | 54 | systemd-run --user \ |
diff --git a/src/ioslay-mgr.sh b/src/firefox-io-slayer index 56ab849..56ab849 100755 --- a/src/ioslay-mgr.sh +++ b/src/firefox-io-slayer | |||