mirror of
https://github.com/nginx/nginx.git
synced 2026-05-13 09:36:42 +00:00
Align per peer lock to cache line boundary in ngx_http_upstream_rr_peer_s
Before: ngx_uint_t down; /* 144 8 */ unsigned route:1; /* 152 4 */ unsigned zombie:1; /* 152 4 */ ngx_atomic_t lock; /* 160 8 */ <-- CL2, offset 32 ngx_uint_t refs; /* 168 8 */ lock shares cacheline 2 with down, slow_start, start_time, route, zombie. Workers spinning on lock invalidate these fields for the lock holder. down/slow_start/start_time are read without the lock in the health check and weight calculation paths. After: /* --- cacheline 3 boundary (192 bytes) --- */ ngx_atomic_t lock; /* 192 8 */ <-- CL3, offset 0 ngx_uint_t refs; /* 200 8 */ ngx_http_upstream_host_t *host; /* 208 8 */ lock starts cacheline 3. refs and host are only accessed while holding the lock, so sharing is harmless. This roughly costs 48 bytes padding per upstream peer in the shared zone.
This commit is contained in:
parent
067d766f21
commit
a4e4b102e3
1 changed files with 1 additions and 1 deletions
|
|
@ -80,7 +80,7 @@ struct ngx_http_upstream_rr_peer_s {
|
|||
#if (NGX_HTTP_UPSTREAM_ZONE)
|
||||
unsigned zombie:1;
|
||||
|
||||
ngx_atomic_t lock;
|
||||
ngx_atomic_t lock __attribute__((aligned(64)));
|
||||
ngx_uint_t refs;
|
||||
ngx_http_upstream_host_t *host;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue