免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3689 | 回复: 11
打印 上一主题 下一主题

[C] why malloc on linux is faster than aix? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-16 16:03 |只看该作者 |倒序浏览
testing_alloc_memory:

loop 20,000, 000 times,  
in every loop I alloc 256byte memory and then free it.

I just do this simple test on aix5.3 and linux RHEL5, and I drawed the conclusion :" malloc on linux is much faster  on aix!"
because the exhaust time of the same test on linux is only about 1/3 as on AIX!

and  I tried set env variables like MALLOCOPTIONS and tested very values,  but the result still has no change.

Could anyone give me some advices?

[ 本帖最后由 picobsd 于 2009-1-16 16:30 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2009-01-16 16:57 |只看该作者
库函数引起的差异。

这个差异意义不大。
如果要得到真正有意义的结果,你应该将分配来的内存都写上数值,再比较他们的速度。

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:172015亚冠之水原三星
日期:2015-06-02 16:34:202015年亚冠纪念徽章
日期:2015-10-19 18:13:37程序设计版块每日发帖之星
日期:2015-11-08 06:20:00
3 [报告]
发表于 2009-01-16 16:58 |只看该作者
SLUB,SLAB,还有glibc的封装有关

论坛徽章:
0
4 [报告]
发表于 2009-01-16 17:02 |只看该作者
库的MALLOC不用SLUB,SLAB. 间接用到了alloc_pages(在真实物理内存分配时候)

原帖由 xinglp 于 2009-1-16 16:58 发表
SLUB,SLAB,还有glibc的封装有关

论坛徽章:
0
5 [报告]
发表于 2009-01-16 17:22 |只看该作者
原帖由 思一克 于 2009-1-16 17:02 发表
库的MALLOC不用SLUB,SLAB. 间接用到了alloc_pages(在真实物理内存分配时候)




but, what shall I do to speed up  malloc on aix when I have to alloc small amount mem frequently in my apps?

论坛徽章:
0
6 [报告]
发表于 2009-01-16 17:26 |只看该作者
原帖由 picobsd 于 2009-1-16 17:22 发表



but, what shall I do to speed up  malloc on aix when I have to alloc small amount mem frequently in my apps?

memory pool

论坛徽章:
0
7 [报告]
发表于 2009-01-16 17:26 |只看该作者
你自己可以加一层分配。

还有,一般到不了影响你程序的程度。

原帖由 picobsd 于 2009-1-16 17:22 发表



but, what shall I do to speed up  malloc on aix when I have to alloc small amount mem frequently in my apps?

论坛徽章:
0
8 [报告]
发表于 2009-01-16 18:08 |只看该作者
楼主先按照二楼版主的提议,把分配出来的内存都写上数值,然后再做测试。注意,是都写上。
这个结果才有意义,个人觉得差异应该不会有这么大。

论坛徽章:
0
9 [报告]
发表于 2009-01-16 20:43 |只看该作者
拿 libc 测试没意思,要测就用底层一点的 API
比如 Linux 就用 sbrk(),NT RtlAllocateHeap()

论坛徽章:
0
10 [报告]
发表于 2009-01-17 01:10 |只看该作者
原帖由 picobsd 于 2009-1-16 00:03 发表
testing_alloc_memory:

loop 20,000, 000 times,  
in every loop I alloc 256byte memory and then free it.

I just do this simple test on aix5.3 and linux RHEL5, and I drawed the conclusion :"  ...

如果你的测试与实际使用场景差别太大,测试结果是没什么意义的。实际使用上你也总是分配256字节然后释放,如此反复?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP