malloc and gcc optimization

醉酒当歌 提交于 2019-12-12 00:31:44

问题


I've written some memory allocation code in c as an exercise. It is translated almost purely to macro now. By doing this I've been able to reduce allocation time to something similar to glibc malloc (unoptimized). However, running the test with gcc -Ox where x > 0, I can't get anywhere near glibc's speed -- glibc beats me by around 10^2

I understand that the glibc malloc implementation is based on Doug Lea's dlmalloc and the comments suggest the code does benefit from optimizing compilers. I haven't looked into why this is and I am not clued up on compiler optimization tricks and was wondering if anybody knew or could give a hint on what techniques are commonly used?

来源:https://stackoverflow.com/questions/17848426/malloc-and-gcc-optimization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!