Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unix benchmark #32

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions AnsiblePlaybooks/meerkat/roles/unix-bench/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- name: install gcc
dnf:
name: gcc
state: present
become: true
when: ansible_distribution != 'Ubuntu'

- name: install make
dnf:
name: make
state: present
become: true
when: ansible_distribution != 'Ubuntu'

- name: Install git
dnf:
name: git
state: present
become: true
when: ansible_distribution != 'Ubuntu'

- name: copy over data extraction
ansible.builtin.template:
src: extract_results.sh.j2
dest: ~/extract_results.sh
mode: '0755'

- name: Install unix-bench
git:
repo: https://github.com/kdlucas/byte-unixbench
dest: ~/byte-unixbench

- name: Run Unix bench
shell: cd byte-unixbench/UnixBench; ./Run

- name: extract results
shell: cd results; ./extract_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#! /bin/bash

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -euo pipefail so it will fail if something goes wrong

Additionally can we setup shell-check like so: https://github.com/stfc/SCD-OpenStack-Utils/blob/master/.github/workflows/gpu_benchmark.yaml#L11

Since this more scripts we add without linting the harder it will be in the future

# get file name
cd ~/byte-unixbench/UnixBench/results/
pattern="unix*"
files=( $pattern )
file="${files[0]}"
echo $file

sed -i -e 's/(//g' $file
sed -i -e 's/)//g' $file

extract_data() {
string=$1
# Extarct the number of numbers in the string to calculate which ones to extract
numbers=$(echo $string | grep -oP "\d+(?:\.\d+)?" | wc -l)
n1=$((1 + $numbers))
n2=$(($n1 + $numbers + $numbers + 2))
# Index score only appears twice, not 4 times
if [[ $string == 'System Benchmarks Index Score' ]]; then
n2=2
fi
# extract benchmark results
echo ------------------------------------
r1=$(grep -ioP "$string +(?)\d+(?:\.\d+)?" $file | grep -oP "\d+(?:\.\d+)?" | head -n$n1 | tail -1)
r2=$(grep -ioP "$string +(?)\d+(?:\.\d+)?" $file | grep -oP "\d+(?:\.\d+)?" | head -n$n2 | tail -1)
# Remove spaces from benchmark name for sending results to DB
bench=$(echo $string | sed -r 's/[ -]/_/g')
echo $bench
echo $r1
echo $r2
# Specify if benchmarks are single core or multicore
bench1="${bench}_single_core"
bench2="${bench}_multi_core"
# Send data to DB
curl -H "Authorization: Basic `echo -n "{{ db_username }}:{{ db_password }}" | base64`" -d 'unix_bench,image='"$image"',flavor='"$flavor"' '"$bench1"'='"$r1"'' -X POST $DB --insecure

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment about --insecure flag?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the host has an invalid cert we can get a proper DNS record and TLS certificate?
That way we don't have to use the --insecure flag going forward

curl -H "Authorization: Basic `echo -n "{{ db_username }}:{{ db_password }}" | base64`" -d 'unix_bench,image='"$image"',flavor='"$flavor"' '"$bench2"'='"$r2"'' -X POST $DB --insecure

}


# Get VM infor
server_UUID=$(curl http://169.254.169.254/openstack/latest/meta_data.json -s | grep -ioP .{8}-.{4}-.{4}-.{4}-.{12})
vm_info=$(openstack server show $server_UUID --os-cloud openstack)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this from the same meta_data.json or cloud-init which should contain all the relevant details rather than having to copy app creds to each VM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address this in future PR

#hypervisor=$(echo $vm_info | grep -ioP "\w*.nubes.rl.ac.uk" | head -1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is there in case we ever want HV information, but it requires admin creds to do so

flavor=$(echo $vm_info | grep -ioP "flavor\s\|\s\S*" | cut -c 10-)
image=$(echo $vm_info | grep -ioP "image\s\|\s\S*" | cut -c 9-)

DB="https://{{ db_ip }}:{{ db_port }}/write"


benchmarks=(
'Dhrystone 2 using register variables'
'Double-Precision Whetstone'
'Execl Throughput'
'File Copy 1024 bufsize 2000 maxblocks'
'File Copy 256 bufsize 500 maxblocks'
'File Copy 4096 bufsize 8000 maxblocks'
'Pipe Throughput'
'Pipe-based Context Switching'
'Process Creation'
'Shell Scripts 1 concurrent'
'Shell Scripts 8 concurrent'
'System Call Overhead'
'System Benchmarks Index Score'
)


for i in ${!benchmarks[@]}; do
extract_data "${benchmarks[$i]}"
done