登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
登录
注册
9月20日,Gitee × 模力方舟来成都了!聚焦 AI 应用在开发范式、算力架构、交互设计、硬件选型等跨场景创新实践,点击立即报名~
代码拉取完成,页面将自动刷新
开源项目
>
数据库相关
>
数据库服务
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
442
Star
1.5K
Fork
1.8K
openGauss
/
openGauss-server
代码
Issues
960
Pull Requests
165
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
35% of the cost being spent on updating the statistics and possible cacheline optimization
待办的
#I51KOD
任务
mysqlonarm
创建于
2022-04-07 17:31
**Is this a BUG REPORT or FEATURE REQUEST?**: Optimization Request > Uncomment only one, leave it on its own line: > > - bug > - feature/performance optimization **What happened**: 1. instr_unique_sql_count helps configure how many unique sql to collect. 2. Default value is 100 which means 100 unique sqls will be collected. 3. If the said feature is enabled (by setting instr_unique_sql_count > 0) it would cause a lot of other information to get updated related to the said SQL statement. 4. Mainly we are concerned with following 2 information set: 1. different timing (like db, cpu, etc...): UpdateUniqueSQLTimeStat() 2. different n/w stats (like send, recv, etc...): UpdateUniqueSQLNetInfo 5. Together it causes 10+12 = 22 stats to get updated and all of them are atomic (or mutex/semaphore protected). 6. Assuming N threads are updating these 22 stats for each query it is easy to imagine contention. 7. Infact, perf points out it to be top-function with 35% of the time being used in the said stats update. + 35.52% 134097 TPLworker gaussdb [.] UpdateUniqueSQLStat 8. Stats are more for information or plan creation but 35% cost is non-justifiable for queries. 9. Ideally, we should look into how this could be optimized or reduced by a significant margin. **What you expected to happen**: Solution-1: As part of the said exercise, I tried some ideas 1. Given the stats are updated by N different threads at same time and all of them are co-located it naturally is giving rise to cacheline contention. 2. To avoid this I tried to place all the stats on different cacheline. [Yes, it would increase the space requirement but given the global one-time instance that small increase by a few bytes is undervalued by the performance improvement we see from it Of course, there are ways to make use of these additional padding bytes. I will try and experiment with that aspect too]. 3. With the cacheline aligned, there is 6% reduction in the said contention + 29.23% 136291 TPLworker gaussdb [.] UpdateUniqueSQLStat 4. Given complex software like DB, running in multithreaded mode, it follows a timing model that has a wider impact on final throughput. 5. Performance for higher concurrency has shown improvement in the range of 5-13%. (Check the attached graph). **How to reproduce it (as minimally and precisely as possible)**: * pgbench select workload with default instr_unique_sql_count should able to reproduce it. * here is the sample configuration I have used https://github.com/mysqlonarm/benchmark-suites/blob/master/ogsql-pbench/conf/ogsql.cnf/ogsql.conf **Anything else we need to know?**: I have the patch ready but still trying to findout proper way to contribute. Given I am new to opengauss community can you help me direct on this front especially branch/test/validation etc.. Will add the patch here for quick reference. diff --git a/src/include/instruments/instr_unique_sql.h b/src/include/instruments/instr_unique_sql.h index 9b58a5de..6dc9bc8f 100644 --- a/src/include/instruments/instr_unique_sql.h +++ b/src/include/instruments/instr_unique_sql.h @@ -38,12 +38,16 @@ typedef struct { int64 max_time; /* max time for unique sql entry's history events */ } UniqueSQLElapseTime; +const size_t cacheline_factor = PG_CACHE_LINE_SIZE / sizeof(uint64); + typedef struct UniqueSQLTime { - int64 TimeInfoArray[TOTAL_TIME_INFO_TYPES]; + int64& operator[](int idx) { return TimeInfoArray[idx * cacheline_factor]; } + int64 TimeInfoArray[TOTAL_TIME_INFO_TYPES * cacheline_factor]; } UniqueSQLTime; typedef struct UniqueSQLNetInfo { - uint64 netInfoArray[TOTAL_NET_INFO_TYPES]; + uint64& operator[](int idx) { return netInfoArray[idx * cacheline_factor]; } + uint64 netInfoArray[TOTAL_NET_INFO_TYPES * cacheline_factor]; } UniqueSQLNetInfo; typedef struct UniqueSQLWorkMemInfo { **Environment**: - Version: opengauss v2.1.0 - OS (e.g. from /etc/os-release): NAME="openEuler" VERSION="20.03 (LTS-SP2)" ID="openEuler" VERSION_ID="20.03" PRETTY_NAME="openEuler 20.03 (LTS-SP2)" ANSI_COLOR="0;31" - Kernel (e.g. `uname -a`): Linux openEuler169 4.19.90-2106.3.0.0095.oe1.aarch64 #1 SMP Wed Jun 23 14:51:58 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux - Install tools: pgbench - Others:
**Is this a BUG REPORT or FEATURE REQUEST?**: Optimization Request > Uncomment only one, leave it on its own line: > > - bug > - feature/performance optimization **What happened**: 1. instr_unique_sql_count helps configure how many unique sql to collect. 2. Default value is 100 which means 100 unique sqls will be collected. 3. If the said feature is enabled (by setting instr_unique_sql_count > 0) it would cause a lot of other information to get updated related to the said SQL statement. 4. Mainly we are concerned with following 2 information set: 1. different timing (like db, cpu, etc...): UpdateUniqueSQLTimeStat() 2. different n/w stats (like send, recv, etc...): UpdateUniqueSQLNetInfo 5. Together it causes 10+12 = 22 stats to get updated and all of them are atomic (or mutex/semaphore protected). 6. Assuming N threads are updating these 22 stats for each query it is easy to imagine contention. 7. Infact, perf points out it to be top-function with 35% of the time being used in the said stats update. + 35.52% 134097 TPLworker gaussdb [.] UpdateUniqueSQLStat 8. Stats are more for information or plan creation but 35% cost is non-justifiable for queries. 9. Ideally, we should look into how this could be optimized or reduced by a significant margin. **What you expected to happen**: Solution-1: As part of the said exercise, I tried some ideas 1. Given the stats are updated by N different threads at same time and all of them are co-located it naturally is giving rise to cacheline contention. 2. To avoid this I tried to place all the stats on different cacheline. [Yes, it would increase the space requirement but given the global one-time instance that small increase by a few bytes is undervalued by the performance improvement we see from it Of course, there are ways to make use of these additional padding bytes. I will try and experiment with that aspect too]. 3. With the cacheline aligned, there is 6% reduction in the said contention + 29.23% 136291 TPLworker gaussdb [.] UpdateUniqueSQLStat 4. Given complex software like DB, running in multithreaded mode, it follows a timing model that has a wider impact on final throughput. 5. Performance for higher concurrency has shown improvement in the range of 5-13%. (Check the attached graph). **How to reproduce it (as minimally and precisely as possible)**: * pgbench select workload with default instr_unique_sql_count should able to reproduce it. * here is the sample configuration I have used https://github.com/mysqlonarm/benchmark-suites/blob/master/ogsql-pbench/conf/ogsql.cnf/ogsql.conf **Anything else we need to know?**: I have the patch ready but still trying to findout proper way to contribute. Given I am new to opengauss community can you help me direct on this front especially branch/test/validation etc.. Will add the patch here for quick reference. diff --git a/src/include/instruments/instr_unique_sql.h b/src/include/instruments/instr_unique_sql.h index 9b58a5de..6dc9bc8f 100644 --- a/src/include/instruments/instr_unique_sql.h +++ b/src/include/instruments/instr_unique_sql.h @@ -38,12 +38,16 @@ typedef struct { int64 max_time; /* max time for unique sql entry's history events */ } UniqueSQLElapseTime; +const size_t cacheline_factor = PG_CACHE_LINE_SIZE / sizeof(uint64); + typedef struct UniqueSQLTime { - int64 TimeInfoArray[TOTAL_TIME_INFO_TYPES]; + int64& operator[](int idx) { return TimeInfoArray[idx * cacheline_factor]; } + int64 TimeInfoArray[TOTAL_TIME_INFO_TYPES * cacheline_factor]; } UniqueSQLTime; typedef struct UniqueSQLNetInfo { - uint64 netInfoArray[TOTAL_NET_INFO_TYPES]; + uint64& operator[](int idx) { return netInfoArray[idx * cacheline_factor]; } + uint64 netInfoArray[TOTAL_NET_INFO_TYPES * cacheline_factor]; } UniqueSQLNetInfo; typedef struct UniqueSQLWorkMemInfo { **Environment**: - Version: opengauss v2.1.0 - OS (e.g. from /etc/os-release): NAME="openEuler" VERSION="20.03 (LTS-SP2)" ID="openEuler" VERSION_ID="20.03" PRETTY_NAME="openEuler 20.03 (LTS-SP2)" ANSI_COLOR="0;31" - Kernel (e.g. `uname -a`): Linux openEuler169 4.19.90-2106.3.0.0095.oe1.aarch64 #1 SMP Wed Jun 23 14:51:58 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux - Install tools: pgbench - Others:
评论 (
2
)
登录
后才可以发表评论
状态
待办的
已答复
待办的
进行中
已完成
已拒绝
负责人
未设置
标签
sig/storageengine
未设置
项目
未立项任务
未立项任务
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (17)
标签 (29)
master
6.0.0
master_bak08271930
5.0.0
bugfix_0725
3.0.0
7.0.0-RC1
iud_dev
dev_board
5.1.0
kms
2.0.0
3.1.0
2.1.0
1.1.0
1.0.1
1.0.0
v6.0.2
v7.0.0-RC1
v6.0.1
v3.0.6
v6.0.0
v3.0.5B009
v5.0.3
v5.0.2
v6.0.0-RC1
v3.0.5
v5.0.1
v5.1.0
5.1.0
v5.0.0
v3.0.3
v3.1.1
v3.0.2
v3.1.0
v2.0.5
v3.0.1
v2.0.4
v2.0.3
v3.0.0
v2.1.0
v2.0.1
v2.0.0
v1.1.0
v1.0.1
v1.0.0
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
预计工期
(小时)
参与者(1)
C++
1
https://gitee.com/opengauss/openGauss-server.git
git@gitee.com:opengauss/openGauss-server.git
opengauss
openGauss-server
openGauss-server
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册