Live data from Hacker News

Why Intel Added Cache Partitioning

danluu.com

31–40 of 56 posts

Re: Why Intel Added Cache Partitioning

#31

Earlier quoted context omitted.

Golang also has a totally inaccurate routine for counting the CPUs in the machine.

What's the accurate way?

Probably something like hwloc which can be configured to show you only the cpus you're allowed to use.

BTW the same problem also happens for determining available memory in containers.

Re: Why Intel Added Cache Partitioning

#32

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...

Seems like if they did some other metric, it could overcount the number of CPUs instead, right?

What about changing GOMAXPROCS once per minute in a goroutine that calls NumCPU()?

Re: Why Intel Added Cache Partitioning

#33
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…

A lot of those optimizations would no longer yield any benefits[0]. The CPU archictecture evolved a lot in 16 years, especially in branch/code prediction to the point where a correctly predicted branch (without branch_likely) has almost no cost.

[0]: At least, this is true for x86 CPUs.

Re: Why Intel Added Cache Partitioning

#34

Earlier quoted context omitted.

Golang also has a totally inaccurate routine for counting the CPUs in the machine.

What's the accurate way?

As usual, erlang does it better: http://www.erlang.org/doc/man/erlang.html#system_info_cpu_to... and http://www.erlang.org/doc/man/erlang.html#logical_processors

Re: Why Intel Added Cache Partitioning

#35
post #33
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…

A lot of those optimizations would no longer yield any benefits[0]. The CPU archictecture evolved a lot in 16 years, especially in branch/code prediction to the point where a correctly predicted branch (without branch_likely) has almost no cost. [0]: At least, this is true for x86 CPUs.

Ditto for prefetch instructions:

https://lwn.net/Articles/444336/

A MIPS is probably the exact opposite to modern (which actually means anything P6 and above) x86 CPUs in terms of performance characteristics. If I were to guess what member of the x86 family might actually benefit from such optimisation, it would be NetBurst (which itself has very different performance characteristics from every other x86 family that came before or after it.)

Re: Why Intel Added Cache Partitioning

#36
post #33
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…

A lot of those optimizations would no longer yield any benefits[0]. The CPU archictecture evolved a lot in 16 years, especially in branch/code prediction to the point where a correctly predicted branch (without branch_likely) has almost no cost. [0]: At least, this is true for x86 CPUs.

I've occasionally wondered how long it takes highly optimized C/C++ to be surpassed by optimizing compilers due to CPU advancement and the optimizations either making compiler optimization harder, or the optimizations target assumptions about CPU architecture that are no longer valid.

That is, what is the shelf life of a very low level CPU optimization for Intel hardware.

Re: Why Intel Added Cache Partitioning

#37
post #33
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…

A lot of those optimizations would no longer yield any benefits[0]. The CPU archictecture evolved a lot in 16 years, especially in branch/code prediction to the point where a correctly predicted branch (without branch_likely) has almost no cost. [0]: At least, this is true for x86 CPUs.

As a CPU architect, I can confirm that all those except possibly 2) will not yield significant benefits. Prefetching hints will only be useful when the particular code fragment is highly memory-bound because most wide superscalar microarchitectures will easily hide L1/L2 miss latencies.

Re: Why Intel Added Cache Partitioning

#38
post #5

This also helps prevent cache side-channel attacks like the one that led to stealing RSA private keys by probing the L3 miss times. https://eprint.iacr.org/2015/898.pdf

You beat me to it. Partitioned caches have been explored for years to defeat covert timing channels. Other measures were used decades ago with varying success. I was excited at the title thinking Intel was finally on some bandwagon for suppressing timing channels given cloud market, security concerns, etc.

Another performance enhancement lol. That's good, too, but damnit I was hoping they mentioned timing channels. It will have to be thoroughly scrutinized before relied on for that but it's a start for sure. Hopefully, more than that. :)

Re: Why Intel Added Cache Partitioning

#39

To me putting high-priority low-latency process and a low-priority high-throughput process on the same machine is a recipe for disaster - they will find some way to get entangled and hurt each other. Kudos to google for pulling this out but the article shows that you need expertise on all levels of the stack to attempt this. Most of us are better off with simply buying more boxes :)

Or we can automate this in an OS/cluster manager and safely this with everyone like we do with some many other technologies that are difficult for most of us to develop :)

Re: Why Intel Added Cache Partitioning

#40
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.

Never use a single workload as a predictor of performance of the universe of all other workloads. The best benchmark is not a benchmark at all – it is your actual workload.
Post reply on HN