From 4ef7f125076118b6cfddf555068212b1b5be7987 Mon Sep 17 00:00:00 2001 From: "Laio O. Seman" Date: Wed, 14 Feb 2024 14:38:50 -0300 Subject: [PATCH 1/2] add(dash): pgo --- dash/PKGBUILD | 62 ++++++++++++++++++++++++++++++++++ dash/workload.dash | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 dash/PKGBUILD create mode 100644 dash/workload.dash diff --git a/dash/PKGBUILD b/dash/PKGBUILD new file mode 100644 index 00000000..ee3254b8 --- /dev/null +++ b/dash/PKGBUILD @@ -0,0 +1,62 @@ +# Maintainer: Levente Polyak +# Contributor: Dan McGee + +pkgname=dash +pkgver=0.5.12 +pkgrel=2 +pkgdesc='POSIX compliant shell that aims to be as small as possible' +url='http://gondor.apana.org.au/~herbert/dash/' +arch=('x86_64') +license=('BSD') +depends=('glibc' 'libedit' 'libedit.so') +install=dash.install +source=(https://git.kernel.org/pub/scm/utils/dash/dash.git/snapshot/${pkgname}-${pkgver}.tar.gz + workload.dash) +sha512sums=('a5d2347465c0bad09a2921ecb55fb4e7fe451d627ed43c1da82b92259b539857c7a7f153dfee73cea4befcbb34388bb3585845148631262dfe6dec87390f049c') +b2sums=('e0751946fa3b6d513901cc98f3f39a48013f624b9a8ffd699e849456604b856866bd6da268560e6ffa9ec5b91976930d830297031804fdcbab82a953720ee973') + +prepare() { + cd ${pkgname}-${pkgver} + autoreconf -fiv +} + +build() { + + export CFLAGS="${CFLAGS} -fprofile-generate -fprofile-update=atomic -fprofile-partial-training" + export CXXFLAGS="${CXXFLAGS} -fprofile-generate -fprofile-update=atomic -fprofile-partial-training" + + cd ${pkgname}-${pkgver} + ./configure \ + --prefix=/usr \ + --bindir=/usr/bin \ + --mandir=/usr/share/man \ + --exec-prefix="" \ + --with-libedit + make V=1 + + cd .. + ${pkgname}-${pkgver}/src/dash workload.dash + + export CFLAGS="${CFLAGS//-fprofile-generate/}" + export CFLAGS="${CFLAGS//-fprofile-update=atomic/}" + export CXXFLAGS="${CXXFLAGS//-fprofile-generate/}" + export CXXFLAGS="${CXXFLAGS//-fprofile-update=atomic/}" + export CFLAGS="${CFLAGS} -fprofile-use" + + cd ${pkgname}-${pkgver} + make clean + ./configure \ + --prefix=/usr \ + --bindir=/usr/bin \ + --mandir=/usr/share/man \ + --exec-prefix="" \ + --with-libedit + make V=1 + +} + +package() { + cd ${pkgname}-${pkgver} + make DESTDIR="${pkgdir}" install + install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}" +} diff --git a/dash/workload.dash b/dash/workload.dash new file mode 100644 index 00000000..37272fa7 --- /dev/null +++ b/dash/workload.dash @@ -0,0 +1,83 @@ +#!/bin/dash + +# Increase complexity of mathematical computations +calculate_fibonacci() { + n=$1 + if [ $n -le 1 ]; then + echo $n + else + echo $(( $(calculate_fibonacci $((n - 1))) + $(calculate_fibonacci $((n - 2))) )) + fi +} + +# Calculating a larger set of prime numbers +calculate_primes() { + n=$1 + count=0 + number=2 + primes="" + while [ $count -lt $n ]; do + is_prime=1 + for i in $(seq 2 $(expr $number / 2)); do + if [ $(expr $number % $i) -eq 0 ]; then + is_prime=0 + break + fi + done + if [ $is_prime -eq 1 ]; then + primes="$primes $number" + count=$((count + 1)) + fi + number=$((number + 1)) + done + echo $primes +} + +# Simulating heavier data processing +generate_large_data() { + for i in $(seq 1 100000); do + echo $RANDOM + done > large_data.txt +} + +sort_large_data() { + sort -n large_data.txt -o sorted_large_data.txt +} + +filter_large_data() { + awk '{if ($1 % 2 == 0) print}' sorted_large_data.txt > filtered_large_data.txt +} + +# More complex file I/O operations +complex_file_operations() { + echo "Generating large files for I/O operations..." + for i in $(seq 1 10); do + for j in $(seq 1 10000); do + echo "Line $j of file $i" >> "file_${i}.txt" + done + done + + echo "Reading from large files..." + for i in $(seq 1 10); do + while IFS= read -r line; do + echo "/dev/null" + done < "file_${i}.txt" + done +} + +# Main execution starts here +echo "Calculating Fibonacci for 20..." +calculate_fibonacci 20 + +echo "Calculating first 100 prime numbers..." +calculate_primes 100 + +echo "Generating, sorting, and filtering large dataset..." +generate_large_data +sort_large_data +filter_large_data + +echo "Performing complex file write and read operations..." +complex_file_operations + +echo "All tasks completed." From 894ce8512e57ea61f6f9a71cca6807eb816f4d29 Mon Sep 17 00:00:00 2001 From: "Laio O. Seman" Date: Wed, 14 Feb 2024 14:41:20 -0300 Subject: [PATCH 2/2] fix(dash): add missing post-install --- dash/dash.install | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dash/dash.install diff --git a/dash/dash.install b/dash/dash.install new file mode 100644 index 00000000..6b04cba3 --- /dev/null +++ b/dash/dash.install @@ -0,0 +1,11 @@ +post_install() { + grep -q '/bin/dash' etc/shells || echo '/bin/dash' >> etc/shells +} + +post_upgrade() { + post_install +} + +pre_remove() { + sed -i '/^\/bin\/dash/d' etc/shells +}