Live data from Hacker News

Why Intel Added Cache Partitioning

danluu.com

11–20 of 56 posts

Re: Why Intel Added Cache Partitioning

#11
post #7

Regarding cpusets, I wonder how much contention is being created just by software assuming the number of cpus match the number of cpus in the affinity set. For example, C++ has hardware_concurrency now, Python has cpu_count , Java has fork-join, etc...

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

What's the accurate way?

Re: Why Intel Added Cache Partitioning

#12
post #7

Regarding cpusets, I wonder how much contention is being created just by software assuming the number of cpus match the number of cpus in the affinity set. For example, C++ has hardware_concurrency now, Python has cpu_count , Java has fork-join, etc...

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

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

Re: Why Intel Added Cache Partitioning

#14
post #9

> Xkcd estimated that Google owns 2 million machines Xkcd doesn't sound like a very convincing source. And at least this estimation should have some error-bars.

Of all the sources outside of Google, I'd say XKCD is likely to be closer than most. Even if you ignore the fact that Randall (XKCD) spends a good amount of his time estimating things in a rigorous and scientific way that would mean his estimates are actually pretty good, he has the exact background that means people at Google would take his call if he picked up the phone to muse upon the question of how many machines Google has. They might not give specifics, but helping would be a pretty cool thing to do so they'd probably do it.

Re: Why Intel Added Cache Partitioning

#15
post #14
post #9

> Xkcd estimated that Google owns 2 million machines Xkcd doesn't sound like a very convincing source. And at least this estimation should have some error-bars.

Of all the sources outside of Google, I'd say XKCD is likely to be closer than most. Even if you ignore the fact that Randall (XKCD) spends a good amount of his time estimating things in a rigorous and scientific way that would mean his estimates are actually pretty good, he has the exact background that means people at Google would take his call if he picked up the phone to muse upon the question of how many machine…

Such a situation did happen, Randall answered how many punch cards it would take to store all of the data in google datacenters (https://what-if.xkcd.com/63/). In response, google sent him punch cards (http://blog.ted.com/using-serious-math-to-answer-weird-quest...).

Re: Why Intel Added Cache Partitioning

#17
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 :)

Re: Why Intel Added Cache Partitioning

#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 rid of the stall cycles.

1) Use branch_likely to force gcc to make sure there is no branch at all in the critical path of executions. (save 30+ cpu cycle per branch, there are a lot of branch stall cycles if one just simplely follow the gcc generated "optimized" code. MIPS CPU 200Mhz)

2) Use prefetch ahead of data structure access to get rid of un-cache data delay. (save ~50+cpu cycle per data stall, also, there are lot of them in the critical path.)

3) Use inline functions, etc to get rid of call stalls in critical path.

The system got ~100x increase on the overall system thru-put with those techniques with just pure C optimization from standard -O2 build.

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.

Specifying which code path / function call sequences are the real critical path probably still require programmer's touch.

As result of using data prefetch code in proper place, I don't used cache locking nor doing any kind of CPU affinity trick to generated the optimized obj code without any stall cycles for critical code path.

Re: Why Intel Added Cache Partitioning

#19

Earlier quoted context omitted.

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

What's the accurate way?

At the very least you should be aware that these counts usually count cores with hyperthreading twice - and hyperthreading does indeed provide opportunity for increased parallelism but it is noticeably worse than having another separate physical core.

Re: Why Intel Added Cache Partitioning

#20
post #12

Earlier quoted context omitted.

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

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.
Post reply on HN