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

5.1.0版本适配fedora SG2042 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhangfeiv0
Copy link

【总体方案】
我们适配了v5.1.0版本的openGauss-third_party和openGauss-server,并最终能够在竞赛组委会提供的rvbox11上直接运行Benchmarksql5.0。由于没有采用官方推荐的openEuler、Centos操作系统或者容器的方式,这也导致了我们花了很多时间去搭建编译环境。具体步骤包括:

【复现步骤】
以下操作均可在rvbox11上直接进行,涉及路径需自行修改位置。
1. gcc编译
我们尝试过使用gcc13.2去编译openGauss,但最终由于c++语法问题,导致我们还是选择了官方推荐的gcc10.3版本,在rvbox11上本地编译gcc步骤如下:

mkdir file; cd file
wget https://mirrors.aliyun.com/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.gz
tar -xvf gcc-10.3.0.tar.gz
cd gcc-10.3.0/
mkdir build; cd build
../configure --prefix=/home/zhangf/file/gcc103-install3 --build=riscv64-unknown-linux-gnu --target=riscv64-unknown-linux-gnu --enable-languages=c,c++ --disable-multilib
make -j; make install

gcc编译过程中会遇到重复定义问题,可参考以下链接解决:
[3] gcc-mirror/gcc@2701442
安装完毕后,需要继续修改下gcc:

cd /home/zhangf/file/gcc103-install3/lib/gcc/riscv64-unknown-linux-gnu/10.3.0
ln -s ../../../libstdc++.so.6.0.28 libstdc++.so.6
ln -s ../../../libstdc++.so.6.0.28 libstdc++.so
ln -s ../../../libgomp.so.1.0.0 libgomp.so.1
ln -s ../../../libgomp.so.1.0.0 libgomp.so
ln -s ../../../libgcc_s.so.1 libgcc_s.so
ln -s ../../../libatomic.so.1.2.0 libatomic.so.1
ln -s ../../../libatomic.so.1.2.0 libatomic.so
cp ../../../libgomp.spec .
cd /home/zhangf/file/gcc103-install3/
cp -r lib lib64

设置gcc环境变量:
vi ~/.bashrc中添加export PATH=/home/zhangf/file/gcc103-install3/bin:$PATH,然后source ~/.bashrcgcc -v看下是否成功:

[zhangf@fedora-riscv ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/data/home/zhangf/file/gcc103-install3/bin/../libexec/gcc/riscv64-unknown-linux-gnu/10.3.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: ../configure --prefix=/home/zhangf/file/gcc103-install3 --build=riscv64-unknown-linux-gnu --target=riscv64-unknown-linux-gnu --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (GCC)

2. 环境依赖编译
我们在移植过程中发现,由于使用了gcc10.3,导致一些系统下的软件不能正常使用,比如cmake,因此,这里用gcc10.3重新编译了依赖包,下面罗列出所需的软件包版本及下载链接:

export PATH=/home/zhangf/file/ccache-install/usr/local/bin/:/home/zhangf/file/apache-maven-3.6.1/bin:/home/zhangf/file/apache-ant-1.10.8/bin:/home/zhangf/file/gcc103-install3/bin:/home/zhangf/file/cmake-install/bin:/home/zhangf/file/doxygen-install/usr/local/bin:$PATH

然后执行source ~/.bashrc

3. openGauss-third_party编译
说明:由于时间关系,numactl包和build_component.sh编译的5个包(cbb dcc dcf dms dss),我们直接进入到了对应软件包修改了源码解决编译问题,通过build.sh构建会重新解压源码并覆盖,因此暂时不能通过sh build.sh一键构建,这里提供编译出的binarylibs的二进制文件(详见附录),并且已将gcc10.3移动进去了,后期我们会改成为打补丁方式,通过build.sh脚本编译。其余修改可见附录[6]提供的补丁,编译所需的riscv jdk8也在附录[3]提供了。

也正是由于环境并非官方推荐的,我们发现了esdk_obs_api软件包中build_obs.sh脚本里路径拼写错误导致该包无法正常编译,该问题在上游master、v5.1.0以及其他分支均存在该问题,我已给上游提交了补丁,详见以下链接:
[4] https://gitee.com/opengauss/openGauss-third_party/pulls/240/files

4. openGauss-server编译
(1)拉取本pr
(2)调用build.sh 进行全量编译

cd /home/zhangf/openGauss-server
sh build.sh -3rd /home/zhangf/binarylibs

最终在mppdb-temp-install目录下得到编译好的openGauss。然后在.bashrc上设置openGauss和jdk的环境变量:

export GAUSSHOME=/home/zhangf/openGauss-server/mppdb_temp_install
export PATH=/home/zhangf/file/ccache-install/usr/local/bin/:$GAUSSHOME/bin:/home/zhangf/file/apache-maven-3.6.1/bin:/home/zhangf/file/apache-ant-1.10.8/bin:/home/zhangf/binarylibs/kernel/platform/openjdk8/riscv64/jdk/bin:/home/zhangf/file/gcc103-install3/bin:/home/zhangf/file/cmake-install/bin:/home/zhangf/file/doxygen-install/usr/local/bin:$PATH
export JAVA_HOME=/home/zhangf/binarylibs/kernel/platform/openjdk8/riscv64/jdk
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/jre
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
export LD_LIBRARY_PATH=/home/zhangf/openGauss-server/mppdb_temp_install/lib:$LD_LIBRARY_PATH

执行source ~/.bashrc,接着初始化数据库:

mkdir data log
touch log/opengauss.log
gs_initdb -D /home/zhangf/data --nodename=db1 
gs_ctl start -D /home/zhangf/data -Z single_node -l /home/zhangf/log/opengauss.log

# gsl进入openGauss并修改密码
gsql -d postgres 

openGauss=# alter role "zhangf" password 'zhangf@123';
openGauss=# \q

openGauss

5. Benchmarksql5.0编译与测试
由于时间关系,本次测试只采用了默认配置进行测试,测试步骤如下:
(1)下载Benchmarksql5.0并解压,链接如下:
[5] https://sourceforge.net/projects/benchmarksql/
(2)替换jdbc驱动
这里由于官方提供链接里只有x86和arm架构的驱动(https://opengauss.org/zh/download/) ,我们在SG2042上编译了openGauss-connector-jdbc包,并生成了相应的驱动,步骤如下:

git clone https://gitee.com/opengauss/openGauss-connector-jdbc.git
cd ./openGauss-connector-jdbc/
git checkout 5.1.0
sh build.sh

最终在当前目录会出现openGauss-5.0.0-UNKNOWN-64bit-Jdbc.tar.gz,然后替换驱动:

cd benchmarksql-5.0/lib/postgres/
cp /home/zhangf/openGauss-connector-jdbc/openGauss-5.0.0-UNKNOWN-64bit-Jdbc.tar.gz .
mv postgresql-9.3-1102.jdbc41.jar postgresql-9.3-1102.jdbc41.jar.bak
tar -xvf openGauss-5.0.0-UNKNOWN-64bit-Jdbc.tar.gz

(3)编译
进入benchmarksql-5.0根目录,输入ant命令进行编译:

cd benchmarksql-5.0
ant

(4)修改配置
进入benchmarksql-5.0/run,修改props.pg,主要修改了user与password配置如下:

db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://localhost:5432/postgres
user=zhangf
password=zhangf@123

warehouses=1
loadWorkers=4

terminals=1
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=10
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=0
//Number of total transactions per minute
limitTxnsPerMin=300

//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true

//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
//resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
//osCollectorScript=./misc/os_collector_linux.py
//osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

(5)运行Benchmark

sh runDatabaseBuild.sh props.pg  ## 生成测试数据
sh runBenchmark.sh props.pg      ## TPCC测试

结果如下:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
02:53:24,625 [main] INFO jTPCC : Term-00,
02:53:24,637 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
02:53:24,638 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
02:53:24,639 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
02:53:24,640 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
02:53:24,640 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
02:53:24,648 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
02:53:24,649 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
02:53:24,650 [main] INFO jTPCC : Term-00,
02:53:24,651 [main] INFO jTPCC : Term-00, db=postgres
02:53:24,651 [main] INFO jTPCC : Term-00, driver=org.postgresql.Driver
02:53:24,652 [main] INFO jTPCC : Term-00, conn=jdbc:postgresql://localhost:5432/postgres
02:53:24,653 [main] INFO jTPCC : Term-00, user=zhangf
02:53:24,653 [main] INFO jTPCC : Term-00,
02:53:24,654 [main] INFO jTPCC : Term-00, warehouses=1
02:53:24,655 [main] INFO jTPCC : Term-00, terminals=1
02:53:24,669 [main] INFO jTPCC : Term-00, runTxnsPerTerminal=10
02:53:24,670 [main] INFO jTPCC : Term-00, limitTxnsPerMin=300
02:53:24,671 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=true
02:53:24,671 [main] INFO jTPCC : Term-00,
02:53:24,672 [main] INFO jTPCC : Term-00, newOrderWeight=45
02:53:24,673 [main] INFO jTPCC : Term-00, paymentWeight=43
02:53:24,674 [main] INFO jTPCC : Term-00, orderStatusWeight=4
02:53:24,674 [main] INFO jTPCC : Term-00, deliveryWeight=4
02:53:24,675 [main] INFO jTPCC : Term-00, stockLevelWeight=4
02:53:24,676 [main] INFO jTPCC : Term-00,
02:53:24,676 [main] INFO jTPCC : Term-00, resultDirectory=null
02:53:24,677 [main] INFO jTPCC : Term-00, osCollectorScript=null
02:53:24,678 [main] INFO jTPCC : Term-00,
Feb 28, 2024 2:53:25 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [7fe1a3b7-84f3-48ea-93ef-107dde7b41a5] Try to connect. IP: localhost:5432
Feb 28, 2024 2:53:31 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [127.0.0.1:58832/ocalhost/127.0.0.1:5432] Connection is established. ID: 7fe1a3b7-84f3-48ea-93ef-107dde7b41a5
Feb 28, 2024 2:53:31 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 7fe1a3b7-84f3-48ea-93ef-107dde7b41a5
02:53:32,050 [main] INFO jTPCC : Term-00, C value for C_LAST during load: 141
02:53:32,051 [main] INFO jTPCC : Term-00, C value for C_LAST this run: 33
02:53:32,051 [main] INFO jTPCC : Term-00,
Feb 28, 2024 2:53:32 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl5MB
INFO: [c5fcaab5-5f1c-4dff-b0da-69b830a6aaaf] Try to connect. IP: localhost:5432
Feb 28, 2024 2:53:38 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [127.0.0.1:60550/ocalhost/127.0.0.1:5432] Connection is established. ID: c5fcaab5-5f1c-4dff-b0da-69b830a6aaaf
Feb 28, 2024 2:53:38 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: c5fcaab5-5f1c-4dff-b0da-69b830a6aaaf
Term-00, Running Average tpmTOTAL: 291.97 Current tpmTOTAL: 120 Memory Usage: 6MB / 15MB
02:53:40,639 [Thread-1] INFO jTPCC : Term-00,
02:53:40,640 [Thread-1] INFO jTPCC : Term-00,
02:53:40,642 [Thread-1] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 101.47
02:53:40,643 [Thread-1] INFO jTPCC : Term-00, Measured tpmTOTAL = 279.06
02:53:40,644 [Thread-1] INFO jTPCC : Term-00, Session Start = 2024-02-28 02:53:38
02:53:40,645 [Thread-1] INFO jTPCC : Term-00, Session End = 2024-02-28 02:53:40
02:53:40,645 [Thread-1] INFO jTPCC : Term-00, Transaction Count = 10

【附录】
以下是移植过程中使用的源码和二进制链接,可以下载使用:
[1] gcc10.3二进制
https://cowtransfer.com/s/5eebd3c39c6748

[2] binarylibs二进制
https://cowtransfer.com/s/60a5a0d47c8b46

[3] 环境依赖二进制(cmake、ccache、doxygen、ant、maven、riscv jdk8)
https://cowtransfer.com/s/94a0e06077b741

[4] opengauss 二进制
https://cowtransfer.com/s/5961e92e2cb644

[5] 基于5.1.0的server补丁
目前竞赛的master分支和5.1.0相差较远,这里专门提供在原始5.1.0的riscv移植补丁,更加清晰
https://cowtransfer.com/s/97097fb705ef4b

[6] 基于5.1.0的third-party补丁
目前,对于numactl包和build_component.sh编译的5个包(cbb dcc dcf dms dss)修改还未放入补丁中,后续我们将支持build.sh构建的补丁更新,暂且可以用[2] 提供的binarylibs二进制去编译server,其余修改可见补丁
https://cowtransfer.com/s/c6c7827e1fb74a

[7] opengauss jdbc riscv驱动
https://cowtransfer.com/s/139ed8beae394f

除此之外,组委会可登录rvbox11的zhangf账户,该目录存放着移植的所有文件,目录结构如下:

[zhangf@fedora-riscv ~]$ tree -L 1
.
├── binarylibs   # server依赖的三方库
├── data           #  openGauss数据
├── file             # 环境依赖,包括cmake、ccache、doxygen、ant、maven、riscv jdk8
├── log             # openGauss日志
├── openGauss-connector-jdbc  # 驱动
├── openGauss-server                 # 二进制位于mppdb_temp_install
├── openGauss-third_party         
└── perf_test    # Benchmarksql5.0

最后感谢竞赛组委会提供的技术支持与SG2042平台~

@6eanut
Copy link

6eanut commented Mar 12, 2024

[8]基于5.1.0的third-party补丁v1
将numactl包和build_component.sh编译的5个包(cbb dcc dcf dms dss)的修改放入补丁中
5.1.0-3rd-party-riscv-v1.patch

@sunmin89
Copy link

尊敬的参赛选手,您好。
本次锦标赛您所提交的 PR 初步复测结果如 https://github.com/plctlab/rvspoc/blob/main/Results/Verifications/S2305/README.md 所示。如有任何异议请回复本条评论。如确认无误请回复 “确认无误”,感谢您的配合。

@6eanut
Copy link

6eanut commented Mar 26, 2024 via email

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.

3 participants