PostgreSQL 并行计算 在 xfs, ext4 下的表现

关于PostgreSQL 9.6 基于CPU并行计算的文章,之前写过几篇,请参考
https://yq.aliyun.com/articles/44655
https://yq.aliyun.com/articles/44649

本文主要是对EXT4和XFS进行测试比较,两者在并行度上的性能差异。
文件系统的格式化参数以及挂载参数如下
XFS

mkfs.xfs -f -b size=4096 -l logdev=/dev/dfc1,size=2047868928,sunit=16 -d agsize=536862720 /dev/dfc2

/dev/dfc2 /u03 xfs defaults,allocsize=16M,inode64,nobarrier,nolargeio,logbsize=262144,noatime,nodiratime,swalloc,logdev=/dev/dfc1 0 0

EXT4

mkfs.ext4 /dev/dfc1

e2label /dev/dfc1 u03

LABEL=u03               /u03            ext4            defaults,noatime,nodiratime,nodelalloc,barrier=0,data=writeback 0 0



测试数据和 https://yq.aliyun.com/articles/44655 一样, 90GB。
xfs
测试发现直到22个并发,性能才开始出现拐点,并且在64个并发时回落没有EXT4那么明显。

postgres=# set max_parallel_degree =64 ;  
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 18310.130 ms

postgres=# set max_parallel_degree =32;
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 21144.919 ms

postgres=# set max_parallel_degree =17;
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 8905.510 ms

postgres=# set max_parallel_degree =21;
postgres=# select count(*) from t_bit2;
   count    
------------
 1600000000
(1 row)
Time: 7583.344 ms

ext4
测试发现直到17个并发,性能开始出现拐点。

postgres=# set max_parallel_degree =64;
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 32580.853 ms
                          
postgres=# set max_parallel_degree =32;
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 30209.980 ms

postgres=# set max_parallel_degree =17;
postgres=# select count(*) from t_bit2 ;
   count    
------------
 1600000000
(1 row)
Time: 9313.369 ms



从测试结果来看,XFS要优于EXT4,主要体现在可以做到更高的并发,以及更好的性能。
测试环境是centos 6,如果是7的话,XFS表现可能还会更好。


xfs的组策略,对并行的写I/O有较大帮助(如可以在多个组里面并行分配block和inode),格式化时的agcount选项。
所以, XFS对于高并发的写入优势会更加明显,例如单机多实例,或者Greenplum,都是典型的应用场景。

分配组
XFS文件系统内部被分为多个“分配组”,它们是文件系统中的等长线性存储区。
每个分配组各自管理自己的inode和剩余空间。文件和文件夹可以跨越分配组。
这一机制为XFS提供了可伸缩性和并行特性 —— 多个线程和进程可以同时在同一个文件系统上执行I/O操作。
这种由分配组带来的内部分区机制在一个文件系统跨越多个物理设备时特别有用,使得优化对下级存储部件的吞吐量利用率成为可能。



参考
http://baike.baidu.com/view/1222157.htm
man xfs

agcount=value
This is used to specify the number of allocation groups. 
The data section of the filesystem is divided into allocation groups to improve the performance of XFS. More allocation groups imply that more  parallelism  can  be  achieved  when  allocating blocks and inodes. 
The minimum allocation group size is 16 MiB; 
the maximum size is just under 1 TiB.  
The data section of the filesystem is divided into value allocation groups (default value is scaled automatically based on the underlying device size).

agsize=value
This is an alternative to using the agcount suboption. 
The value is the desired size of the allocation group expressed in bytes (usually using the m or g suffixes).  
This value must be a  multiple  of  the filesystem  block  size,  and  must  be  at least 16MiB, and no more than 1TiB, and may be automatically adjusted to properly align with the stripe geometry.  
The agcount and agsize suboptions are mutually exclusive.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值