News for hackers. Stuff that matters.
Re:How Not to Measure Computer System Performance by mstromb on Tuesday November 18, 2014 @05:06PM (#8626683)
Why would linking order affect runtime performance? Something to do with the interaction between offsets and cache, maybe?

Would it be possible to determine ahead of time what order would maximize performance, or would that require profiling?

Re:How Not to Measure Computer System Performance by rectang on Tuesday November 18, 2014 @06:11PM (#8627016)
I'd speculate that if you're unlucky about link order, two hot cache lines may get mapped to the same slot in an N-way associative cache -- whereas if you're lucky, they end up going to different slots and don't continuously evict each other.

With regards to alignment... do linkers typically pack objects so tightly that the start of each object isn't aligned on a cache line boundary? AFAIK they're typically 32, 64, or 128 bytes.

Re:How Not to Measure Computer System Performance by fleitz on Wednesday November 19, 2014 @04:46AM (#8629076)
Cacheline boundary?

Probably, because caches line sizes are an implementation detail, not part of the architectural specification.

Re:How Not to Measure Computer System Performance by lgeek on Tuesday November 18, 2014 @08:44PM (#8627703)
Linking order will affect code and static data order and cache alignment in turn. Similarly, environment variables are pushed on the stack by the kernel. Their size will affect alignment of application data on the stack.

Maybe there are other causes as well.

> Would it be possible to determine ahead of time what order would maximize performance, or would that require profiling?

I think at the very least, you'd need profiling to determine the hot code path, and that can change depending on input...

Re:How Not to Measure Computer System Performance by halayli on Tuesday November 18, 2014 @05:24PM (#8626783)
Guessing, locality of reference might play a role.
Re:How Not to Measure Computer System Performance by fleitz on Wednesday November 19, 2014 @04:48AM (#8629086)
That, the branch predictors, and caching behaviors, n-way, alignment, etc.

It probably explains why different runs vary so widely, I always thought it was other things going on in the OS, never really thought about the caches, etc.

Re:How Not to Measure Computer System Performance by halayli on Wednesday November 19, 2014 @05:08PM (#8632978)
> That, the branch predictors, and caching behaviors, n-way, alignment, etc.

Those all fall under locality of reference, btw. But yeah cache and branch prediction play a huge role in the list.

One thing that stung me in the past was OS scheduling.