Re: [RFC PATCH v8 1/9] Restartable sequences system call

From: Dave Watson
Date: Fri Aug 19 2016 - 19:01:14 EST


On 08/19/16 02:24 PM, Josh Triplett wrote:
> On Fri, Aug 19, 2016 at 01:56:11PM -0700, Andi Kleen wrote:
> > > Nobody gets a cpu number just to get a cpu number - it's not a useful
> > > thing to benchmark. What does getcpu() so much that we care?
> >
> > malloc is the primary target I believe. Saves lots of memory to keep
> > caches per CPU rather than per thread.
>
> Also improves locality; that does seem like a good idea. Has anyone
> written and tested the corresponding changes to a malloc implementation?
>

I had modified jemalloc to use rseq instead of per-thread caches, and
did some testing on one of our services.

Memory usage decreased by ~20% due to fewer caches. Our services
generally have lots and lots of idle threads (~400), and we already go
through a few hoops to try and flush idle thread caches. Threads are
often coming from dependent libraries written by disparate teams,
making them harder to reduce to a smaller number.

We also have quite a few data structures that are sharded
thread-locally only to avoid contention, for example we have extensive
statistics code that would also be a prime candidate for rseq . We
often have to prune some stats because they're taking up too much
memory, rseq would let us fit a bit more in.

jemalloc diff here (pretty stale now):

https://github.com/djwatson/jemalloc/commit/51f6e6f61b88eee8de981f0f2d52bc48f85e0d01

Original numbers posted here:

https://lkml.org/lkml/2015/10/22/588