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

zlog的性能瓶颈问题 --- the speed's bottleneck of zlog problem, any help? #3

Closed
HardySimpson opened this issue Jun 14, 2012 · 4 comments

Comments

@HardySimpson
Copy link
Owner

zlog的性能一直在提高
the speed of zlog get up and up through every version:

./test/speed.record.txt
-------------------------------------------------
v1.0.6
$ time ./test_press_zlog 1 10 100000
real    0m1.798s
user    0m3.140s
sys     0m0.170s

$ time ./test_press_zlog2 1 10 100000
real    0m0.740s
user    0m1.390s
sys     0m0.020s
-------------------------------------------------
v1.0.5
$ time ./test_press_zlog 1 10 100000
real    0m2.776s
user    0m4.300s
sys     0m0.800s

$ time ./test_press_zlog2 1 10 100000
real    0m1.822s
user    0m2.610s
sys     0m0.560s
-------------------------------------------------
v1.0.3
$ time ./test_press_zlog 1 10 100000
real    0m6.418s
user    0m6.240s

$ time ./test_press_zlog2 1 10 100000
real    0m5.359s
user    0m4.410s
sys     0m5.750s
-------------------------------------------------

不过最大的瓶颈,在linux操作系统上,还是strftime,见图
But The biggest bottleneck on my Linux 2.6.32-41 is strftime, see pic

Linux 2.6.32-41 benchmark

在aix就没有这个问题
On Aix 5.3, there is no such problem

AIX 5.3 benchmark

不知大家有没有什么好的办法来解决这个问题?
Any one knows is there a way to solve this problem?

@HardySimpson
Copy link
Owner Author

试图自己写代码替换strftime,结果发现vfprintf的调用开销增加,看来GNU的大爷们实现的很不错!本问题关闭

@bruiselee
Copy link

原因可能是这个:http://stackoverflow.com/questions/8174147/strftime-performance-vs-snprintf
PS1: 这个图里面的profiler名字是什么?
PS2: 前几天下了zlog版本测试,发现当调用时候的格式串参数长度超出一定时候(30个字符左右),程序会抛异常,今天git pull之后问题消失 FYI

@HardySimpson
Copy link
Owner Author

呃,谢谢支持,那个链接我看过了,现在我优化了,缓存结果,如果两次的格式一样,每秒调用strftime一次,大大提高效率

to PS2: git上的版本还在开发中,昨天的版本有些问题……包括16进制输出等

格式串参数长的时候有问题?等新版本有问题再看吧。。在我的test/test_conf.conf里面

date = "date start%n%d(%a--Wed)%n%d(%A--Wednesday)%n%d(%b--Mar)%n%d(%B--March)%n%d(%c--WedMar211:45:262011)%n%d(%C--20)%n%d(%d--02)%n%d(%D--03/02/11)%n%d(%e--2)%n%d(%F--2011-03-02)%n%d(%g--11)%n%d(%G--2011)%n%d(%h--Mar)%n%d(%H--11)%n%d(%I--11)%n%d(%j--061)%n%d(%k-k)%n%d(%l-l)%n%d(%ms--500)%n%d(%m--03)%n%d(%M--45)%n%d(%us--500730)%n%d(%p--AM)%n%d(%r--11:45:26AM)%n%d(%R--11:45)%n%d(%s--epoch)%n%d(%S--26)%n%d(%t--)%n%d(%T--11:45:26)%n%d(%u--3)%n%d(%U--09)%n%d(%V--09)%n%d(%w--3)%n%d(%W--09)%n%d(%x--03/02/11)%n%d(%X--11:45:26)%n%d(%y--11)%n%d(%Y--2011)%n%d(%z--+0800)%n%d(%Z--CST)%n%d(%%--%)%n%d(%J--%J)%ndate end%n"

都可以。

to PS1: 这是valgrind的callgrind结果,用kcachegrind查看

http://blog.dccmx.com/2011/01/callgrind/

@loveyacper
Copy link

试图自己写代码替换strftime,结果发现vfprintf的调用开销增加,看来GNU的大爷们实现的很不错!本问题关闭

可以考虑转为struct tm,然后自己snprintf,比strftime快太多了

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

No branches or pull requests

3 participants