Skip to content

Commit

Permalink
(TOOLS) compare-grep compare-log-mergers build s4 alloc variations
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmoon79 committed Jun 24, 2024
1 parent 21e28b3 commit b42e0f5
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 8 deletions.
65 changes: 62 additions & 3 deletions tools/compare-grep-sort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cd "$(dirname "${0}")/.."
if [[ -d '.git' ]]; then
(set -x; git log -n1 --format='%h %D')
fi
PROGRAM_PASSED=${PROGRAM-}
PROGRAM=${PROGRAM-./target/release/s4}
(set -x; "${PROGRAM}" --version)
# use full path to Unix tools
Expand Down Expand Up @@ -50,6 +51,8 @@ tmp2=$(mktemp -t "compare-s4_grep_XXXXX")
tmp2b=$(mktemp -t "compare-s4-sorted_grep_XXXXX")
md1=$(mktemp -t "compare-s4_s4_XXXXX.md")
md2=$(mktemp -t "compare-s4_s4_XXXXX.md")
md3=$(mktemp -t "compare-s4_s4_XXXXX.md")
md4=$(mktemp -t "compare-s4_s4_XXXXX.md")
mdfinal=${DIROUT-.}/compare-s4_grep_sort.md

function exit_() {
Expand Down Expand Up @@ -122,12 +125,37 @@ declare -ar grep_args=(

# run both programs using hyperfine

if [[ -n "${hyperfine-}" ]]; then
if [[ -n "${hyperfine-}" ]] && [[ -z "${PROGRAM_PASSED}" ]]; then
(
(set -x; cargo clean --quiet; cargo build --release --quiet)
# force reading of FILES from disk to allow any possible caching,
cat "${FILES[@]}" &> /dev/null
set -x
$hyperfine --style=basic --export-markdown ${md1} -N -n "s4" \
$hyperfine --style=basic --export-markdown ${md1} -N -n "s4 (System)" \
-- \
"${PROGRAM} ${s4_args[*]} ${FILES[*]}"
)

echo

(
(set -x; cargo clean --quiet; cargo build --release --quiet --features=mimalloc)
# force reading of FILES from disk to allow any possible caching,
cat "${FILES[@]}" &> /dev/null
set -x
$hyperfine --style=basic --export-markdown ${md2} -N -n "s4 (mimalloc)" \
-- \
"${PROGRAM} ${s4_args[*]} ${FILES[*]}"
)

echo

(
(set -x; cargo clean --quiet; cargo build --release --quiet --features=jemalloc)
# force reading of FILES from disk to allow any possible caching,
cat "${FILES[@]}" &> /dev/null
set -x
$hyperfine --style=basic --export-markdown ${md3} -N -n "s4 (jemalloc)" \
-- \
"${PROGRAM} ${s4_args[*]} ${FILES[*]}"
)
Expand All @@ -140,14 +168,16 @@ if [[ -n "${hyperfine-}" ]]; then
# force reading of FILES from disk to allow any possible caching,
cat "${FILES[@]}" &> /dev/null
set -x
$hyperfine --style=basic --export-markdown ${md2} --shell sh -n "${grep_sort_name}" \
$hyperfine --style=basic --export-markdown ${md4} --shell sh -n "${grep_sort_name}" \
-- \
"$grep -hEe '${regex_dt}' ${FILES[*]} | $sort -t ' ' -k 1 -s"
)

(
cat "${md1}"
cat "${md2}" | tail -n +3
cat "${md3}" | tail -n +3
cat "${md4}" | tail -n +3
) | column -t -s '|' -o '|' > "${mdfinal}"

(set -x; cat "${mdfinal}")
Expand All @@ -162,6 +192,35 @@ fi
TIME_FORMAT='real %e s, Max RSS %M KB, %P %%CPU, (%x)'

(
(set -x; cargo clean --quiet; cargo build --release --quiet)
set -x
$time --format="${TIME_FORMAT}" \
"${@}" \
-- \
"${PROGRAM}" \
"${s4_args[@]}" \
"${FILES[@]}" \
>/dev/null
)

echo

(
(set -x; cargo clean --quiet; cargo build --release --quiet --features=mimalloc)
set -x
$time --format="${TIME_FORMAT}" \
"${@}" \
-- \
"${PROGRAM}" \
"${s4_args[@]}" \
"${FILES[@]}" \
>/dev/null
)

echo

(
(set -x; cargo clean --quiet; cargo build --release --quiet --features=jemalloc)
set -x
$time --format="${TIME_FORMAT}" \
"${@}" \
Expand Down
75 changes: 70 additions & 5 deletions tools/compare-log-mergers/compare-log-mergers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ tmp1=$(mktemp -t "compare-log-mergers_XXXXX.out")
md1=$(mktemp -t "compare-log_mergers_XXXXX.md")
md2=$(mktemp -t "compare-log_mergers_XXXXX.md")
md3=$(mktemp -t "compare-log_mergers_XXXXX.md")
md4=$(mktemp -t "compare-log_mergers_XXXXX.md")
md5=$(mktemp -t "compare-log_mergers_XXXXX.md")
mdfinal=${DIROUT-.}/compare-log_mergers.md

function exit_() {
rm -f "${tmp1}" "${md1}" "${md2}" "${md3}"
rm -f "${tmp1}" "${md1}" "${md2}" "${md3}" "${md4}" "${md5}"
}

trap exit_ EXIT
Expand Down Expand Up @@ -136,7 +138,7 @@ echo
cat "${md1}"
echo

# Super Speedy Syslog Searcher (S4)
# Super Speedy Syslog Searcher (S4) (system)

echo_line

Expand All @@ -146,9 +148,10 @@ PROGRAM_S4=${PROGRAM_S4-./target/release/s4}
echo

(
(set -x; cargo clean --quiet; cargo build --quiet --release)
files_caching
set -x
$hyperfine --style=basic --export-markdown "${md2}" -N -n "s4" \
$hyperfine --style=basic --export-markdown "${md2}" -N -n "s4 (system)" \
-- \
"'${PROGRAM_S4}' -a='${after_dt}' -b='${befor_dt}' --color=never ${files[*]} > /dev/null"
)
Expand All @@ -170,6 +173,66 @@ echo
cat "${md2}"
echo

# Super Speedy Syslog Searcher (S4) (mimalloc)

echo_line

(
(set -x; cargo clean --quiet; cargo build --quiet --release --features=mimalloc)
files_caching
set -x
$hyperfine --style=basic --export-markdown "${md3}" -N -n "s4 (mimalloc)" \
-- \
"'${PROGRAM_S4}' -a='${after_dt}' -b='${befor_dt}' --color=never ${files[*]} > /dev/null"
)
(
files_caching
set -x
$time --format="${TIME_FORMAT}" \
"${@}" \
-- \
"${PROGRAM_S4}" \
"-a=${after_dt}" \
"-b=${befor_dt}" \
"--color=never" \
"${files[@]}" > "${tmp1}"
)
echo
wc -l "${tmp1}"
echo
cat "${md3}"
echo

# Super Speedy Syslog Searcher (S4) (jemalloc)

echo_line

(
(set -x; cargo clean --quiet; cargo build --quiet --release --features=jemalloc)
files_caching
set -x
$hyperfine --style=basic --export-markdown "${md4}" -N -n "s4 (jemalloc))" \
-- \
"'${PROGRAM_S4}' -a='${after_dt}' -b='${befor_dt}' --color=never ${files[*]} > /dev/null"
)
(
files_caching
set -x
$time --format="${TIME_FORMAT}" \
"${@}" \
-- \
"${PROGRAM_S4}" \
"-a=${after_dt}" \
"-b=${befor_dt}" \
"--color=never" \
"${files[@]}" > "${tmp1}"
)
echo
wc -l "${tmp1}"
echo
cat "${md4}"
echo

# logmerger

echo_line
Expand All @@ -186,7 +249,7 @@ echo
(
files_caching
set -x
$hyperfine --style=basic --export-markdown "${md3}" --shell sh -n "${PROGRAM_LM}" \
$hyperfine --style=basic --export-markdown "${md5}" --shell sh -n "${PROGRAM_LM}" \
-- \
"'${PROGRAM_LM}' --inline --output=- --start '${after_dt}' --end '${befor_dt}' ${files[*]} > /dev/null"
)
Expand All @@ -209,7 +272,7 @@ echo
echo
wc -l "${tmp1}"
echo
cat "${md3}"
cat "${md5}"
echo

# logdissect
Expand Down Expand Up @@ -270,6 +333,8 @@ echo
cat "${md1}"
cat "${md2}" | tail -n +3
cat "${md3}" | tail -n +3
cat "${md4}" | tail -n +3
cat "${md5}" | tail -n +3
) | column -t -s '|' -o '|' > "${mdfinal}"

(set -x; cat "${mdfinal}")
Expand Down

0 comments on commit b42e0f5

Please sign in to comment.