Skip to content

Commit 7d5f742

Browse files
authored
Merge pull request #695 from pareenaverma/content_review
Technical review of glibc with LSE
2 parents d69eb02 + 45b5b2b commit 7d5f742

File tree

6 files changed

+125
-105
lines changed

6 files changed

+125
-105
lines changed

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Use glibc with LSE to improve the performance of workloads on Arm servers
2+
title: Use glibc with Large System Extensions (LSE) to improve the performance of workloads on Arm servers
33

44
minutes_to_complete: 60
55

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/_next-steps.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ================================================================================
55

66
next_step_guidance: >
7-
You can continue learning about porting other cloud applications to the Arm architecture for increased performance and cost savings.
7+
You can continue learning about Large System Extensions and how to use them in your applications.
88
# 1-3 sentence recommendation outlining how the reader can generally keep learning about these topics, and a specific explanation of why the next step is being recommended.
99

1010
recommended_path: "/learning-paths/servers-and-cloud-computing/lse"
@@ -18,13 +18,13 @@ recommended_path: "/learning-paths/servers-and-cloud-computing/lse"
1818

1919
further_reading:
2020
- resource:
21-
title: Arm Architecture Reference Manual
22-
link: https://developer.arm.com/documentation/ddi0487/latest
23-
type: documentation
21+
title: Arm's LSE for atomics and MySQL
22+
link: https://mysqlonarm.github.io/ARM-LSE-and-MySQL/
23+
type: blog
2424
- resource:
25-
title: Projects releated with MongoDB
26-
link: https://github.com/mongodb
27-
type: website
25+
title: MongoDB documentation
26+
link: https://www.mongodb.com/docs/
27+
type: documentation
2828

2929
# ================================================================================
3030
# FIXED, DO NOT MODIFY

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/build_glibc_with_lse.md

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,26 @@ layout: "learningpathall"
99
---
1010

1111

12-
## Before you begin
12+
## Overview
1313
"Glibc with LSE" refers to the version of [the GNU C Library (glibc)](https://www.gnu.org/software/libc/) that includes support for [LSE (Large Systems Extensions)](https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/). LSE is an extension to the ARMv8-A architecture that provides enhanced atomic operations and memory model features.
1414

1515
LSE introduces additional atomic instructions and operations, such as Load-Acquire, Store-Release, and Atomic Compare-and-Swap (CAS). These operations allow for more efficient synchronization and concurrent access to shared memory in multi-threaded applications running on ARMv8-A processors.
1616

1717
When glibc is compiled with LSE support, it can take advantage of these enhanced atomic operations provided by the LSE extension. This can potentially improve the performance of multi-threaded applications that heavily rely on atomic operations and synchronization primitives.
1818

19+
## Before you begin
20+
21+
Launch an [Arm based instance](/learning-paths/servers-and-cloud-computing/csp/) running Ubuntu version 20.04.
22+
23+
On your machine, install the dependencies required to build glibc:
24+
25+
```bash
26+
sudo apt update
27+
sudo apt install -y gcc-10 g++-10 gawk bison make
28+
```
1929

2030
## Build and Install Glibc
21-
You can build glibc without installing, or with installing to a specific directory.
31+
You can now checkout the glibc source package and create a build directory:
2232

2333
```bash
2434
cd ~
@@ -29,55 +39,33 @@ build=~/glibc-2.32_build_install/build
2939
mkdir -p $build
3040
cd $build
3141
```
32-
Before execute the command "./glibc/configure", gawk and bison should be installed.
33-
Glibc-2.32 matches gcc-10 perfect, and the version of ld(GNU linker) should not be higher than 2.35.
34-
__So Ubuntu 20.04 is strongly recommended!__
35-
```
36-
sudo apt update
37-
sudo apt install -y gcc-10 g++-10 gawk bison make
38-
```
3942

40-
- __Without installing__
41-
```bash
42-
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10
43-
sudo make -C $build -j$(expr $(nproc) - 1)
44-
```
43+
Configure glibc and run make to build it:
4544

46-
- __OR__
45+
```bash
46+
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10
47+
sudo make -C $build -j$(expr $(nproc) - 1)
48+
```
49+
You have now successfully built glibc from source without LSE.
4750

48-
- __With installing to a specific directory__
49-
```bash
50-
install=~/glibc-2.32_build_install/install
51-
mkdir -p ${install}
52-
sudo make -C $build -j$(expr $(nproc) - 1) install DESTDIR=${install}
53-
sudo make -C $build -j$(expr $(nproc) - 1) localedata/install-locales DESTDIR=${install}
54-
sudo make -C $build -j$(expr $(nproc) - 1) localedata/install-locale-files DESTDIR=${install}
55-
```
51+
Now lets look at how you can build it with LSE support.
5652

53+
## Build glibc With LSE
54+
To build glibc with LSE, you should add `CFLAGS` and `CXXFLAGS` to the configure command.
5755

58-
## With LSE
59-
If you want to build glibc with LSE, you should add `CFLAGS` and `CXXFLAGS` to configure implicitly or explicitly.
56+
You can do this one of two ways. One way is to use "-mcpu=native" which tells the compiler to detect the architecture/micro-architecture of your machine. The other way is to pass the exact architecture option of your machine to the compiler using "-mcpu=neoverse-n2+lse"
57+
58+
Both ways to configure are shown below:
6059

6160
```bash
6261
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10 CFLAGS="-mcpu=native -O3" CXXFLAGS="-mcpu=native -O3"
6362
sudo make -C $build -j$(expr $(nproc) - 1)
6463
```
6564
OR
65+
6666
```bash
6767
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10 CFLAGS="-mcpu=neoverse-n2+lse -O3" CXXFLAGS="-mcpu=neoverse-n2+lse -O3"
6868
sudo make -C $build -j$(expr $(nproc) - 1)
6969
```
7070

71-
##
72-
73-
## With NO-LSE
74-
75-
```bash
76-
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10
77-
sudo make -C $build -j$(expr $(nproc) - 1)
78-
```
79-
OR
80-
```bash
81-
sudo bash ~/glibc/configure --prefix=/usr --disable-werror CC=gcc-10 CXX=g++-10 CFLAGS="-mcpu=neoverse-n2+nolse -O3" CXXFLAGS="-mcpu=neoverse-n2+nolse -O3"
82-
sudo make -C $build -j$(expr $(nproc) - 1)
83-
```
71+
After running make, you should see glibc (libc.so.6) with LSE support in your build directory.

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/compare_result.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ weight: 6 # 1 is first, 2 is second, etc.
77
layout: "learningpathall"
88
---
99

10-
Now you can run the mongodb benchmark using Glibc with LSE and NoLSE and compare the results.
10+
You can run the mongodb benchmark using Glibc with LSE and NoLSE and compare the results. This will give you an idea of the performance gained by using Glibc with LSE.
1111

1212
## Result with No-LSE
1313
Launch MongoDB with Glibc without LSE and obtain benchmark result.
14-
The overall TPS is __6662.1275371047195__ with No-LSE Glibc.
15-
```console
14+
The output will look similar to:
15+
16+
```output
1617
[OVERALL], RunTime(ms), 750511
1718
[OVERALL], Throughput(ops/sec), 6662.1275371047195
1819
[TOTAL_GCS_G1_Young_Generation], Count, 3527
@@ -58,11 +59,13 @@ The overall TPS is __6662.1275371047195__ with No-LSE Glibc.
5859
[SCAN], 99thPercentileLatency(us), 70143
5960
[SCAN], Return=OK, 1499804
6061
```
62+
The overall throughtput (operations/sec) is 6662.1275371047195 with No-LSE Glibc.
6163

6264
## Result with LSE
63-
Launch MongoDB with Glibc with LSE and obtain benchmark result.
64-
The overall TPS is __6871.605426919102__ with LSE Glibc.
65-
___So you can get around 3.14% extra benefit through Glibc with LSE!___
65+
Launch MongoDB again, this time with Glibc with LSE and obtain benchmark result.
66+
67+
The output will look similar to:
68+
6669
```console
6770
[OVERALL], RunTime(ms), 727632
6871
[OVERALL], Throughput(ops/sec), 6871.605426919102
@@ -109,4 +112,7 @@ ___So you can get around 3.14% extra benefit through Glibc with LSE!___
109112
[SCAN], 99thPercentileLatency(us), 67455
110113
[SCAN], Return=OK, 1499682
111114
```
115+
The overall throughput (operations/sec) is 6871.605426919102 when using Glibc with LSE.
116+
In this case you can get around 3.14% performance uplift by using Glibc with LSE.
117+
112118

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/mongo_benchmark.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,45 @@ Overall, YCSB has become a standard benchmarking tool in the cloud and distribut
2222
You are now ready to benchmark MongoDB with YCSB on your Arm server!
2323

2424
## YCSB Setup
25-
Setup the YCSB on a benchmark machine with __JAVA__:
25+
Install Java on your machine:
26+
2627
```console
2728
sudo apt-get install -y openjdk-11-jdk
29+
```
30+
Download the uncompress the YCSB Benchmark source:
31+
32+
```console
2833
cd ~
2934
wget -c https://github.com/brianfrankcooper/YCSB/releases/download/0.17.0/ycsb-0.17.0.tar.gz
3035
tar xfvz ycsb-0.17.0.tar.gz
3136
```
3237

33-
Create a workload file with the following content:
38+
Using a file editor of your choice, create a workload file `~/ycsb-0.17.0/workloads/iworkload`. Copy and save the following content into this file:
39+
3440
```
35-
vi ~/ycsb-0.17.0/workloads/iworkload
36-
37-
recordcount=1000
38-
operationcount=1000
39-
workload=site.ycsb.workloads.CoreWorkload
40-
readallfields=true
41-
readproportion=0.2
42-
updateproportion=0.3
43-
scanproportion=0.3
44-
insertproportion=0
45-
readmodifywriteproportion=0.2
46-
requestdistribution=zipfian
41+
recordcount=1000
42+
operationcount=1000
43+
workload=site.ycsb.workloads.CoreWorkload
44+
readallfields=true
45+
readproportion=0.2
46+
updateproportion=0.3
47+
scanproportion=0.3
48+
insertproportion=0
49+
readmodifywriteproportion=0.2
50+
requestdistribution=zipfian
4751
4852
```
4953

50-
## YCSB Run
51-
1. To run YCSB, you need following the `load` command first:
52-
```console
53-
~/ycsb-0.17.0/bin/ycsb.sh load mongodb -s -P ~/ycsb-0.17.0/workloads/iworkload -p recordcount=10000000 -threads 256 -p mongodb.url="mongodb://${mongo_ip}:${mongo_port}/mymongodb"
54-
```
55-
You can see the result after the `load` command finishes:
56-
```out
54+
## Run YCSB
55+
To run YCSB, you need following the `load` command first:
56+
```console
57+
~/ycsb-0.17.0/bin/ycsb.sh load mongodb -s -P ~/ycsb-0.17.0/workloads/iworkload -p recordcount=10000000 -threads 256 -p mongodb.url="mongodb://${mongo_ip}:${mongo_port}/mymongodb"
58+
```
59+
60+
Replace `mongo_ip` and `mongo_port` in the command above with the IP address and port number of the machine you are running MongoDB on.
61+
62+
You should see the result from the benchmark after the `load` command finishes:
63+
```output
5764
/usr/bin/java -classpath /root/workload/tools/ycsb-0.17.0/conf:/root/workload/tools/ycsb-0.17.0/lib/core-0.17.0.jar:/root/workload/tools/ycsb-0.17.0/lib/HdrHistogram-2.1.4.jar:/root/workload/tools/ycsb-0.17.0/lib/htrace-core4-4.1.0-incubating.jar:/root/workload/tools/ycsb-0.17.0/lib/jackson-core-asl-1.9.4.jar:/root/workload/tools/ycsb-0.17.0/lib/jackson-mapper-asl-1.9.4.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/logback-core-1.1.2.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongodb-binding-0.17.0.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongo-java-driver-3.8.0.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/slf4j-api-1.7.25.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/snappy-java-1.1.7.1.jar site.ycsb.Client -load -db site.ycsb.db.MongoDbClient -s -P /root/workload/tools/ycsb-0.17.0/workloads/iworkloadf -p recordcount=10000000 -threads 256 -p mongodb.url=mongodb://172.26.202.189:27017/mymongodb
5865
mongo client connection created with mongodb://172.26.202.189:27017/mymongodb
5966
[OVERALL], RunTime(ms), 241978
@@ -80,16 +87,20 @@ requestdistribution=zipfian
8087
[INSERT], 95thPercentileLatency(us), 7563
8188
[INSERT], 99thPercentileLatency(us), 14991
8289
[INSERT], Return=OK, 10000000
83-
```
90+
```
91+
92+
You can now benchmark the performance of MongoDB following the `run` command:
93+
```console
94+
~/ycsb-0.17.0/bin/ycsb.sh run mongodb -s -P ~/ycsb-0.17.0/workloads/iworkload -p operationcount=5000000 -threads 256 -p mongodb.url="mongodb://${mongo_ip}:${mongo_port}/mymongodb"
95+
```
96+
Replace `mongo_ip` and `mongo_port` in the command above with the IP address and port number of the machine you are running MongoDB on.
8497

85-
2. Then you can benchmark the performance of MongoDB following the `run` command:
86-
```
87-
~/ycsb-0.17.0/bin/ycsb.sh run mongodb -s -P ~/ycsb-0.17.0/workloads/iworkload -p operationcount=5000000 -threads 256 -p mongodb.url="mongodb://${mongo_ip}:${mongo_port}/mymongodb"
88-
```
89-
__Attention: Please ensure that you have sufficient disk space available!__
98+
{{% notice Note %}}
99+
Please ensure that you have sufficient disk space available!
100+
{{% /notice %}}
90101

91-
You can see the performance data after the `run` command execution is finished.
92-
```output
102+
You can see the performance data after the `run` command execution is finished.
103+
```output
93104
/usr/bin/java -classpath /root/workload/tools/ycsb-0.17.0/conf:/root/workload/tools/ycsb-0.17.0/lib/core-0.17.0.jar:/root/workload/tools/ycsb-0.17.0/lib/HdrHistogram-2.1.4.jar:/root/workload/tools/ycsb-0.17.0/lib/htrace-core4-4.1.0-incubating.jar:/root/workload/tools/ycsb-0.17.0/lib/jackson-core-asl-1.9.4.jar:/root/workload/tools/ycsb-0.17.0/lib/jackson-mapper-asl-1.9.4.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/logback-core-1.1.2.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongodb-binding-0.17.0.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/mongo-java-driver-3.8.0.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/slf4j-api-1.7.25.jar:/root/workload/tools/ycsb-0.17.0/mongodb-binding/lib/snappy-java-1.1.7.1.jar site.ycsb.Client -t -db site.ycsb.db.MongoDbClient -s -P /root/workload/tools/ycsb-0.17.0/workloads/iworkloadf -p operationcount=5000000 -threads 256 -p mongodb.url=mongodb://172.26.202.189:27017/mymongodb
94105
mongo client connection created with mongodb://172.26.202.189:27017/mymongodb
95106
[OVERALL], RunTime(ms), 774685
@@ -136,6 +147,5 @@ requestdistribution=zipfian
136147
[SCAN], 95thPercentileLatency(us), 101183
137148
[SCAN], 99thPercentileLatency(us), 125375
138149
[SCAN], Return=OK, 1499379
139-
140-
```
150+
```
141151

content/learning-paths/servers-and-cloud-computing/glibc-with-lse/mongo_start.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ weight: 3 # 1 is first, 2 is second, etc.
77
layout: "learningpathall"
88
---
99

10-
You are now ready to start MongoDB utilizing the newly built glibc with LSE on your Arm server.
10+
In this section you will learn how to start using MongoDB with the newly built glibc with LSE on your Arm machine.
1111

1212

13-
## MongoDB Setups
14-
Build and install MongoDB version `5.3.2`:
13+
## MongoDB Setup
14+
15+
Build and install MongoDB version `5.3.2` from source using the commands shown:
16+
1517
```console
16-
#for Fedora/RHEL
17-
sudo yum install -y git gcc g++ python3-devel openssl-devel libcurl-devel
18-
#for Ubuntu/Debian
1918
sudo apt install -y git gcc g++ python-dev-is-python3 python3-pip libssl-dev libcurl4-openssl-dev liblzma-dev
20-
2119
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
2220

2321
cd ~
@@ -28,37 +26,54 @@ sudo python3 -m pip install -r etc/pip/compile-requirements.txt
2826
sudo python3 buildscripts/scons.py install-mongod -j$(expr $(nproc) - 1) --disable-warnings-as-errors
2927
```
3028

31-
## MongoDB Starts utilizing the newly built Glibc with LSE
29+
## Configure and run MongoDB utilizing the newly built Glibc with LSE
30+
31+
Create a directory for MongoDB to store its data files:
32+
3233
```console
3334
cd ~
3435
mkdir -p ~/mongodb-5.3.2/data
35-
vi ~/mongodb-5.3.2/mongodb.conf
36+
```
3637

38+
Create a file named `mongodb.conf` in the ~/mongodb-5.3.2 directory using a file editor of your choice.
39+
Copy and save the contents shown below into this configuration file:
40+
41+
```console
3742
dbpath=mongodb-5.3.2/data
3843
logpath=mongodb-5.3.2/mongodb.log
3944
pidfilepath=mongodb-5.3.2/data/mongo.pid
4045
logappend=true
4146
bind_ip=0.0.0.0
4247
port=27017
48+
```
49+
You can now run MongoDB as shown:
4350

44-
#if necessary
45-
#rm -rf /mongodb-5.3.2/data/*
51+
```console
52+
cp /usr/lib/aarch64-linux-gnu/libcrypt.so ~/glibc-2.32_build_install/build/crypt/
4653
~/glibc-2.32_build_install/build/testrun.sh ~/mongo/build/install/bin/mongod -f ~/mongodb-5.3.2/mongodb.conf --wiredTigerCacheSizeGB=20
54+
```
4755

48-
#If you encounter an error related to libcrypt.so and need to execute the following command before running again:
49-
#cp /usr/lib/aarch64-linux-gnu/libcrypt.so ~/glibc-2.32_build_install/build/crypt/
56+
Confirm that the workload mongodb runs is with the newly built glibc with LSE:
57+
58+
First, get the pid with the following command.
59+
```console
60+
ps -ef | grep mongo
5061
```
5162

52-
Confirm if the workload mongodb runs with the newly built glibc with LSE:
53-
- First, get the pid with the following command.
54-
```console
55-
ps -ef | grep mongo
63+
The output will look similar to:
64+
65+
```output
5666
root 19852 1 1 16:33 ? 00:00:01 /root/glibc-2.32_build_install/build/elf/ld-linux-aarch64.so.1 --library-path /root/glibc-2.32_build_install/build:/root/glibc-2.32_build_install/build/math:/root/glibc-2.32_build_install/build/elf:/root/glibc-2.32_build_install/build/dlfcn:/root/glibc-2.32_build_install/build/nss:/root/glibc-2.32_build_install/build/nis:/root/glibc-2.32_build_install/build/rt:/root/glibc-2.32_build_install/build/resolv:/root/glibc-2.32_build_install/build/mathvec:/root/glibc-2.32_build_install/build/support:/root/glibc-2.32_build_install/build/crypt:/root/glibc-2.32_build_install/build/nptl /root/mongo/build/install/bin/mongod -f /mongodb-5.3.2/mongodb.conf --wiredTigerCacheSizeGB=20
57-
```
67+
```
5868

59-
- Then execute the following command to check.
60-
```
61-
cat /proc/19852/smaps | grep glibc
69+
Next, execute the following command using the correct `pid`:
70+
71+
```console
72+
cat /proc/19852/smaps | grep glibc
73+
```
74+
The output should look similar to:
75+
76+
```output
6277
ffff898c5000-ffff898cd000 r-xp 00000000 103:02 953511 /root/glibc-2.32_build_install/build/crypt/libcrypt.so
6378
ffff898cd000-ffff898e4000 ---p 00008000 103:02 953511 /root/glibc-2.32_build_install/build/crypt/libcrypt.so
6479
ffff898e4000-ffff898e5000 r--p 0000f000 103:02 953511 /root/glibc-2.32_build_install/build/crypt/libcrypt.so
@@ -90,5 +105,6 @@ Confirm if the workload mongodb runs with the newly built glibc with LSE:
90105
ffff90333000-ffff90355000 r-xp 00000000 103:02 943577 /root/glibc-2.32_build_install/build/elf/ld.so
91106
ffff90372000-ffff90373000 r--p 0002f000 103:02 943577 /root/glibc-2.32_build_install/build/elf/ld.so
92107
ffff90373000-ffff90375000 rw-p 00030000 103:02 943577 /root/glibc-2.32_build_install/build/elf/ld.so
93-
94108
```
109+
110+
This output shows that the newly built glibc with LSE is being utilized.

0 commit comments

Comments
 (0)