问题
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