Skip to content

Conversation

salvatoredipietro
Copy link

We would like to propose this optimization for ARM architecture that, at runtime, it switches to SB instruction if supported by the system. SB (Speculation Barrier) is a modern barrier, available from armv8.5a. It achieves the same result as issuing ISB, but without having the CPU to drop its instruction pipeline.

Our performance evaluation based on 50 repetitions of the attached benchmark (inspired from https://bugs.mysql.com/bug.php?id=74832) conducted on Ubuntu 24.04 on m8g.24xlarge AWS instance using trunk MySQL branch, shows on average up to 28% reduction of the script execution time when sb instruction is used. Also linux perf shows ~11% drop of ut_delay function usage. Here the data:

sudo systemctl restart mysqld.service && sudo systemctl status mysqld.service

echo "Loading"
mysql -u root -pmysql < sql
sleep 5s

echo "Warmup"
for i in {1..5}; do 
    /usr/bin/time  --format="%e real,\t%U user,\t%S sys" ./psdoit 500
    sleep 5s;
done

echo "Benchmark"
for i in {1..50}; do 
    /usr/bin/time  --format="%e real,\t%U user,\t%S sys" --output=psdoit.sb.log --append ./psdoit 500
    sleep 5s;
done


# Results
$ cat psdoit.isb.log  | cut -f1 -d' ' | awk '{sum += $1; count++} END {print sum/count}'
32.445
$ cat psdoit.sb.log  | cut -f1 -d' ' | awk '{sum += $1; count++} END {print sum/count}'
24.504

# Perf ut_delay improvement
## ISB
+   18.87%    18.86%  connection  mysqld [.] ut_delay(unsigned long)

## SB
+    7.76%     7.76%  connection  mysqld  [.] ut_delay(unsigned long)

sql.txt
psdoit.txt

@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@salvatoredipietro
Copy link
Author

Submitted OCA request

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@salvatoredipietro
Copy link
Author

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=118302 for updates.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants