Commit b7620169 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give struct req its own buffer for batching VSL records

Size controlled by param vsl_buffer which will replace shm_workspace.
The space comes out of request workspace.
parent c305b19c
......@@ -248,6 +248,7 @@ struct exp {
struct vsl_log {
uint32_t *wlb, *wlp, *wle;
unsigned wlr;
unsigned wid;
};
/*--------------------------------------------------------------------*/
......@@ -615,6 +616,9 @@ struct req {
/* First byte of storage if we free it as we go (pass) */
ssize_t stream_front;
/* Transaction VSL buffer */
struct vsl_log vsl[1];
};
/*--------------------------------------------------------------------
......
......@@ -318,7 +318,7 @@ SES_GetReq(struct sess *sp)
struct sesspool *pp;
uint16_t nhttp;
unsigned sz, hl;
char *p;
char *p, *e;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
pp = sp->sesspool;
......@@ -330,27 +330,38 @@ SES_GetReq(struct sess *sp)
AN(sp->req);
sp->req->magic = REQ_MAGIC;
e = (char*)sp->req + sz;
p = (char*)(sp->req + 1);
sz -= sizeof *sp->req;
p = (void*)PRNDUP(p);
assert(p < e);
nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp);
xxxassert(sz > 3 * hl + 128);
sp->req->http = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
sz -= hl;
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
sp->req->http0 = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
sz -= hl;
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
sp->req->resp = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
sz -= hl;
p += hl;
p = (void*)PRNDUP(p);
assert(p < e);
sz = cache_param->workspace_thread;
VSL_Setup(sp->req->vsl, p, sz);
sp->req->vsl->wid = sp->vsl_id;
p += sz;
p = (void*)PRNDUP(p);
assert(p < e);
WS_Init(sp->req->ws, "req", p, sz);
WS_Init(sp->req->ws, "req", p, e - p);
}
void
......@@ -364,6 +375,7 @@ SES_ReleaseReq(struct sess *sp)
AN(pp->pool);
CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC);
MPL_AssertSane(sp->req);
WSL_Flush(sp->req->vsl, 0);
MPL_Free(pp->mpl_req, sp->req);
sp->req = NULL;
}
......
......@@ -78,6 +78,8 @@ struct params {
unsigned workspace_backend;
unsigned workspace_thread;
unsigned vsl_buffer;
unsigned shm_workspace;
unsigned http_req_size;
unsigned http_req_hdr_len;
......
......@@ -766,6 +766,18 @@ static const struct parspec input_parspec[] = {
"objects allocate exact space for the headers they store.\n",
0,
"64", "header lines" },
{ "vsl_buffer",
tweak_bytes_u, &mgt_param.vsl_buffer, 1024, UINT_MAX,
"Bytes of (req-/backend-)workspace dedicated to buffering"
" VSL records.\n"
"At a bare minimum, this must be longer than"
" the longest HTTP header to be logged.\n"
"Setting this too high costs memory, setting it too low"
" will cause more VSL flushes and likely increase"
" lock-contention on the VSL mutex.\n"
"Minimum is 1k bytes.",
0,
"4k", "bytes" },
{ "shm_workspace",
tweak_bytes_u, &mgt_param.shm_workspace, 4096, UINT_MAX,
"Bytes of shmlog workspace allocated for worker threads. "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment