mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-14 19:16:57 +02:00
OPTIM: server: start to use aligned allocs in server
This is currently for per-thread arrays like idle conns etc. We're now cache-aligning the per-thread arrays so as to put an end to false sharing. A comparative test between no alignment and alignment on a simple config with round robin between 4 servers showed an average rate of 1.75M/s vs 1.72M/s before for 100M requests. The gain seems to be more commonly less than 1% however. This should mostly help make measurements more reproducible across multiple runs.
This commit is contained in:
parent
c2687f587e
commit
1bb9754648
12
src/server.c
12
src/server.c
@ -3122,9 +3122,9 @@ void srv_free_params(struct server *srv)
|
||||
free(srv->hostname);
|
||||
free(srv->hostname_dn);
|
||||
free((char*)srv->conf.file);
|
||||
free(srv->per_thr);
|
||||
free(srv->per_tgrp);
|
||||
free(srv->curr_idle_thr);
|
||||
ha_aligned_free(srv->per_thr);
|
||||
ha_aligned_free(srv->per_tgrp);
|
||||
ha_aligned_free(srv->curr_idle_thr);
|
||||
free(srv->pool_conn_name);
|
||||
release_sample_expr(srv->pool_conn_name_expr);
|
||||
free(srv->resolvers_id);
|
||||
@ -3482,7 +3482,7 @@ int srv_init(struct server *srv)
|
||||
|
||||
/* initialize idle conns lists */
|
||||
if (srv->max_idle_conns != 0) {
|
||||
srv->curr_idle_thr = calloc(global.nbthread, sizeof(*srv->curr_idle_thr));
|
||||
srv->curr_idle_thr = ha_aligned_zalloc(64, global.nbthread * sizeof(*srv->curr_idle_thr));
|
||||
if (!srv->curr_idle_thr) {
|
||||
ha_alert("memory error during idle conn list init for %s/%s server\n",
|
||||
srv->proxy->id, srv->id);
|
||||
@ -5918,8 +5918,8 @@ static int srv_init_per_thr(struct server *srv)
|
||||
{
|
||||
int i;
|
||||
|
||||
srv->per_thr = calloc(global.nbthread, sizeof(*srv->per_thr));
|
||||
srv->per_tgrp = calloc(global.nbtgroups, sizeof(*srv->per_tgrp));
|
||||
srv->per_thr = ha_aligned_zalloc(64, global.nbthread * sizeof(*srv->per_thr));
|
||||
srv->per_tgrp = ha_aligned_zalloc(64, global.nbtgroups * sizeof(*srv->per_tgrp));
|
||||
if (!srv->per_thr || !srv->per_tgrp)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user