Do not waste cache lines with unnecessary paddings.

Make sure paddings are GPR_CACHELINE_SIZE minus the
size of fields in that cache line. Otherwise, we will waste an
additional cache line for no good reason.
pull/16943/head
Soheil Hassas Yeganeh 6 years ago
parent 20c848e88d
commit 1f85f6ba33
  1. 2
      src/core/lib/gpr/mpscq.h
  2. 2
      src/core/lib/iomgr/ev_epoll1_linux.cc

@ -40,7 +40,7 @@ typedef struct gpr_mpscq_node {
typedef struct gpr_mpscq {
gpr_atm head;
// make sure head & tail don't share a cacheline
char padding[GPR_CACHELINE_SIZE];
char padding[GPR_CACHELINE_SIZE - sizeof(head)];
gpr_mpscq_node* tail;
gpr_mpscq_node stub;
} gpr_mpscq;

@ -195,7 +195,7 @@ struct grpc_pollset_worker {
typedef struct pollset_neighborhood {
gpr_mu mu;
grpc_pollset* active_root;
char pad[GPR_CACHELINE_SIZE];
char pad[GPR_CACHELINE_SIZE - sizeof(mu) - sizeof(active_root)];
} pollset_neighborhood;
struct grpc_pollset {

Loading…
Cancel
Save