[PATCH v2] Optimize 64-bit atomic access on RV64 - #422
Open
pg-hub-mirror[bot] wants to merge 1 commit into
Open
pg-hub-mirror[bot] wants to merge 1 commit into
pg-hub-mirror[bot] wants to merge 1 commit into
Conversation
RV64 guarantees that naturally aligned XLEN-wide loads and stores are atomic. Teach PostgreSQL about that property by defining PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY in a new RISC-V atomics header. This allows the generic pg_atomic_read_u64() and pg_atomic_write_u64() implementations to use plain loads and stores instead of compare/exchange loops on RV64. Keep RV32 on the existing generic fallback. Co-authored-by: Ni Jincheng <nijincheng@iscas.ac.cn> Co-authored-by: Yuansheng <yuansheng@isrc.iscas.ac.cn>
Author
|
Earlier design discussion: Discussion #388 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pgsql-hackers162ef016.d668.1a0b26c7630.Coremail.wanghongyan2025@iscas.ac.cnPatch files:
Hi,
Thanks for pointing me to the patch submission guidelines.
Attached is v2. The code change is unchanged from v1. This revision
reformats the commit message and adds the missing submission,
validation, platform, and performance information.
The patch is intended for review and application against PostgreSQL
master.
It defines PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY on RV64, allowing the
generic pg_atomic_read_u64() and pg_atomic_write_u64()
implementations to use naturally aligned plain loads and stores
instead of compare/exchange loops. RV32 remains unchanged.
Validation was performed on PostgreSQL commit
86f7c82.
Test environment:
Results:
lr.d/sc.d loop to ld, while state-updating CAS paths retained LR/SC
The paired pgbench campaign covered 13 workload and concurrency
conditions, with 10 interleaved baseline/candidate runs per condition,
for a total of 130 pairs. Each pair used the same seed, and the
baseline/candidate execution order was alternated.
Results:
These measurements were obtained from one RV64 system and do not
imply the same performance improvement on every RV64 implementation.
No new SQL regression test is included because this change has no
SQL-visible behavior. No user-facing documentation change is needed
because this is an internal architecture-specific optimization.
Changes since v1:
Regards,
Hongyan Wang
-----原始邮件-----
发件人:"wenhui qiu" <qiuwenhuifx(at)gmail(dot)com>
发送时间:2026-09-17 11:30:18 (星期四)
收件人: wanghongyan <wanghongyan2025(at)iscas(dot)ac(dot)cn>
抄送: pgsql-hackers(at)postgresql(dot)org, "Ni Jincheng" <nijincheng(at)iscas(dot)ac(dot)cn>, Yuansheng <yuansheng(at)isrc(dot)iscas(dot)ac(dot)cn>
主题: Re: [PATCH v1] Optimize 64-bit atomic access on RV64
Hi Wanghongyan
You can follow up this document : https://wiki.postgresql.org/wiki/Submitting_a_Patch
Thanks