记录学习过程中的点点滴滴
优化
KFS[CloudStore] 使用fuse挂载方法【原创】
九 15th
1, 下载fuse-2.8.4.tar.gz
2, tar -xzvf fuse-2.8.4.tar.gz
3, ./configure && make && make install
注:需要root权限
4, echo “/usr/local/lib” >> /etc/ld.so.conf
/sbin/ldconfig
5, /sbin/modprobe fuse
如果出现fuse module not found的话,请使用fuse2.7.*版本,因为Fuse网页上提供下载的版本2.8以前的源码中包含kernel模块部分
,2.8及2.8以后的版本不包含kernel模块源码
6, 修改kfs-0.5中CMakeLists.txt中的
SET(Fuse_LIBRARY_DIR “/usr/local/lib”)
SET(Fuse_INCLUDE_DIR “/usr/local/include”)
7, 重新编译kfs-0.5 会在bin目录下生成kfs_fuse二进制文件
8, 启动kfs
9, 编写kfs.prp
metaServer.name=10.60.1.125
metaServer.port=20000
注:kfs.prp这个配置的路径是在kfs_fuse_main.cc中写的,
注意启动时kfs.prp与kfs_fuse是在同一个目录下
10, ./kfs_fuse /tmp/kfs-fuse -f -o allow_other 启动 #-o allow_other 运行其他用户访问
cd /tmp/kfs-fuse 就可以看到当前kfs下的所有数据了
11. fuse的一些参数:
- 其中,影响比较大的参数有
- -s 禁用多线程
- -o allow_other 允许其它用户访问
- -o allow_root 允许root用户访问
- -o nonempty 允许挂载在非空目录上
- -o auto_cache 开启基于修改时间的cache
- -o kernel_cache 开启内核cache
注:kfs-0.5版本中存在bug以及可优化的地方
1, 在fuse_read 和fuse_write 中调用Seek, 判断返回值status应该是大于等于0 而不是等于0
因为status 的值应该是seek后的文件偏移
2, 可以优化的地方,在每次fuse_read 和 fuse_write 时,都会进行open 和close 操作,这样会导致效率上的问题,加入读取很大的数据,导致进行多次open 和 close操作。
优化方法:使用client->Fileno(path) 来获得已经打开的fd ,如果fd不存在的话,再进行Open 操作,在函数结束时不进行
Close 操作,而是将close操作放到fuse_flush函数中(新增的函数),具体作用请参考fuse手册
结束
关于php优化的好文
一 19th
A HOWTO on Optimizing PHP
PHP is a very fast programming language, but there is more to optimizing PHP than just speed of code execution.
In this chapter, we explain why optimizing PHP involves many factors which are not code related, and why tuning PHP requires an understanding of how PHP performs in relation to all the other subsystems on your server, and then identifying bottlenecks caused by these subsystems and fixing them. We also cover how to tune and optimize your PHP scripts so they run even faster.
Achieving High Performance
When we talk about good performance, we are not talking about how fast your PHP scripts will run. Performance is a set of tradeoffs between speed versus accuracy versus scalability. An example of speed versus accuracy is your scripts might be tuned to run fast with caching, but the data will tend to grow stale and be less accurate. For an example of speed versus scalability you could write a script that runs fast by loading everything into memory, or write a more scalable one that only loads data in chunks so that it does not exhaust application memory (Updated 30 Oct 2009 from speed vs scalability to speed vs accuracy vs scalability).
In the example below, A.php is a sprinter that can run fast, and B.php is a marathon runner than can jog forever at the nearly the same speed. For light loads, A.php is substantially faster, but as the web traffic increases, the performance of B.php only drops a little bit while A.php just runs out of steam.
http://phplens.com/lens/php-book/optimizing-debugging-php.php 具体请参看
近期评论