Live data from Hacker News

Why Intel Added Cache Partitioning

danluu.com

21–30 of 56 posts

Re: Why Intel Added Cache Partitioning

#21
post #18

16 years, I created a profiling macro system on for select set critical functions. The profiling system can switch the measuring data from #instruction, #cpu_clk, #branch_stall_cycles, #L1_miss, #L2 miss for all the critical path functions. After analyzed the data, I found branch stall cycles and data access stall cycles were causing huge number of delays in the critical code path. I used the following tricks to get…

So...profiler guided optimization lol.

Re: Why Intel Added Cache Partitioning

#22
post #16

Earlier quoted context omitted.

What's the accurate way?

To calculate the number of processors available or the optimal number of threads/processes?

Well specifically it would be cool if it counted the optimal number to set GOMAXPROCS to, since I think that's like the main use of runtime.NumCPU().

Re: Why Intel Added Cache Partitioning

#23
post #6

The SPECint and SPECfp benchmark suites were never very tightly connected to real-world performance, but I wonder what these figures look like for SPECjbb, the java benchmark. (If I recall correctly, SPECjbb spins up an app that looks a lot like "java pet store" and runs clients against it.)

What I've heard is that you should mostly pay attention to the gcc compilation part of SPEC if you want a good indication of real world performance.

Re: Why Intel Added Cache Partitioning

#24
post #18

16 years, I created a profiling macro system on for select set critical functions. The profiling system can switch the measuring data from #instruction, #cpu_clk, #branch_stall_cycles, #L1_miss, #L2 miss for all the critical path functions. After analyzed the data, I found branch stall cycles and data access stall cycles were causing huge number of delays in the critical code path. I used the following tricks to get…

So...profiler guided optimization lol.

Yeah. Nothing ground-breaking here.

Would still love to have a great open-source tool for this.

Re: Why Intel Added Cache Partitioning

#25
post #16

Earlier quoted context omitted.

To calculate the number of processors available or the optimal number of threads/processes?

Well specifically it would be cool if it counted the optimal number to set GOMAXPROCS to, since I think that's like the main use of runtime.NumCPU().

Right. Currently runtime.NumCPU tries to be fancy by looking at the population count of the cpuset mask[1]. However in a hosted environment using containers there's no reason to believe that the cpuset will remain fixed over the life of the process. This can undercount the available CPUs, leaving you with a GOMAXPROCS that is too low.

1: https://code.google.com/p/go/source/browse/src/pkg/runtime/t...

Re: Why Intel Added Cache Partitioning

#26
post #12

Earlier quoted context omitted.

I'm not necessarily questioning the accuracy, just that they generally don't consider the affinities and a lot of software assumes that number of cpus matches the concurrency available. If only half the cpus are in the affinity set, the processes/threads could generally contend twice as much as possible. I guess depending on how the number is used it could improve the throughput though (e.g. blocking on i/o).

Depends on the language used in the spec, but "CPUs available for scheduling" seems like the definition most software should use. However, I suspect most software is built using an interface that returns the total CPU count for the machine.

The language is typically vague, if there is any. POSIX also notably never had anything to say in regard to cpu affinity.

Re: Why Intel Added Cache Partitioning

#29

Earlier quoted context omitted.

Well specifically it would be cool if it counted the optimal number to set GOMAXPROCS to, since I think that's like the main use of runtime.NumCPU().

Right. Currently runtime.NumCPU tries to be fancy by looking at the population count of the cpuset mask[1]. However in a hosted environment using containers there's no reason to believe that the cpuset will remain fixed over the life of the process. This can undercount the available CPUs, leaving you with a GOMAXPROCS that is too low. 1: https://code.google.com/p/go/source/browse/src/pkg/runtime/t...

Anecdotally, it's very often not bad, (and in fact sometimes "good") to over-provision MAXPROCS. We have used as much as 3 to 6x the number of hyperthreaded cores with good results, depending on the workload. This could insulate you against some container changes.

Re: Why Intel Added Cache Partitioning

#30
post #18

16 years, I created a profiling macro system on for select set critical functions. The profiling system can switch the measuring data from #instruction, #cpu_clk, #branch_stall_cycles, #L1_miss, #L2 miss for all the critical path functions. After analyzed the data, I found branch stall cycles and data access stall cycles were causing huge number of delays in the critical code path. I used the following tricks to get…

    > I think it might be possible to create a build system that can automatically 
    > collect the profiling data (branch stall cycles and data stall cycles) 
    > and use the branch likely and prefetch instructions to auto-optimized the 
    > critical path code.
Recent versions of Clang and GCC actually support profile guided optimizations using gcov format files to trace executions. There are a number optimizations that the compiler can determine profitable knowing how something typically executes. They don't use sampled or simulated metrics though, and I'm not sure if they add prefetch or non-temporal optimizations.

The ones you mentioned aren't exactly equivalent to cache partitioning (etc...) though. Partitioning allows explicit allocation and prioritization of a contended resource instead of only improving utilization for a single process. So, for example if two threads/processes have an 8MiB working set, and they run on the same cpu, they can easily step on eachother's data in the cache. If you partition it though, less frequently used data doesn't have to step on more frequently used data.

Post reply on HN