Commit 71f2b383 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Remove obj->http.

This shaves approx 100 bytes of stored objects, and is a major step
to avoiding storing absolute pointers in persistent stevedores.
parent 080fa4f9
......@@ -576,8 +576,6 @@ struct object {
/* VCL only variables */
char oa_lastmodified[8];
struct http *http;
struct body body[1];
struct storage *esidata;
......@@ -945,7 +943,7 @@ unsigned HTTP_estimate(unsigned nhttp);
void HTTP_Copy(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, uint16_t nhttp);
const char *http_Status2Reason(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
unsigned http_EstimateWS(const struct http *fm, unsigned how);
void HTTP_Init(void);
void http_PutResponse(struct http *to, const char *proto, uint16_t status,
const char *response);
......@@ -1241,8 +1239,7 @@ void RFC2616_Weaken_Etag(struct http *hp);
/* stevedore.c */
struct object *STV_NewObject(struct busyobj *,
const char *hint, unsigned len, uint16_t nhttp);
struct object *STV_NewObject(struct busyobj *, const char *hint, unsigned len);
struct storage *STV_alloc(const struct vfp_ctx *, size_t size);
void STV_trim(struct storage *st, size_t size, int move_ok);
void STV_free(struct storage *st);
......
......@@ -47,7 +47,7 @@
*/
static struct object *
vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp)
vbf_allocobj(struct busyobj *bo, unsigned l)
{
struct object *obj;
struct objcore *oc;
......@@ -67,7 +67,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp)
bo->storage_hint = NULL;
obj = STV_NewObject(bo, storage_hint, l, nhttp);
obj = STV_NewObject(bo, storage_hint, l);
if (obj != NULL)
return (obj);
......@@ -84,7 +84,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp)
oc->exp.ttl = cache_param->shortlived;
oc->exp.grace = 0.0;
oc->exp.keep = 0.0;
obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp);
obj = STV_NewObject(bo, TRANSIENT_STORAGE, l);
return (obj);
}
......@@ -99,7 +99,6 @@ vbf_beresp2obj(struct busyobj *bo)
char *b;
struct vsb *vary = NULL;
int varyl = 0;
uint16_t nhttp;
struct object *obj;
l = 0;
......@@ -127,12 +126,12 @@ vbf_beresp2obj(struct busyobj *bo)
}
l += http_EstimateWS(bo->beresp,
bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp);
bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS);
if (bo->uncacheable)
bo->fetch_objcore->flags |= OC_F_PASS;
obj = vbf_allocobj(bo, l, nhttp);
obj = vbf_allocobj(bo, l);
if (obj == NULL)
return (-1);
......
......@@ -610,12 +610,11 @@ http_PutResponse(struct http *to, const char *proto, uint16_t status,
*/
unsigned
http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
http_EstimateWS(const struct http *fm, unsigned how)
{
unsigned u, l;
l = 4;
*nhd = 1 + HTTP_HDR_FIRST - 3;
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
for (u = 0; u < fm->nhd; u++) {
if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)
......@@ -630,7 +629,6 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
#include "tbl/http_headers.h"
#undef HTTPH
l += Tlen(fm->hd[u]) + 1L;
(*nhd)++;
}
return (PRNDUP(l + 1L));
}
......
......@@ -317,7 +317,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr,
assert(len == sizeof o->oa_lastmodified);
return (o->oa_lastmodified);
case OA_VARY:
o->oa_vary = (void*)WS_Alloc(o->http->ws, len);
o->oa_vary = (void*)WS_Alloc(vc->bo->ws_o, len);
AN(o->oa_vary);
return (o->oa_vary);
case OA_VXID:
......
......@@ -229,8 +229,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size)
struct stv_objsecrets {
unsigned magic;
#define STV_OBJ_SECRETES_MAGIC 0x78c87247
uint16_t nhttp;
unsigned lhttp;
unsigned wsl;
};
......@@ -256,24 +254,20 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
assert(PAOK(ptr));
assert(PAOK(soc->wsl));
assert(PAOK(soc->lhttp));
assert(ltot >= sizeof *o + soc->lhttp + soc->wsl);
assert(ltot >= sizeof *o + soc->wsl);
o = ptr;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
l = PRNDDN(ltot - (sizeof *o + soc->lhttp));
l = PRNDDN(ltot - sizeof *o);
assert(l >= soc->wsl);
o->http = HTTP_create(o + 1, soc->nhttp);
WS_Init(bo->ws_o, "obj", (char *)(o + 1) + soc->lhttp, soc->wsl);
WS_Init(bo->ws_o, "obj", o + 1, l);
WS_Assert(bo->ws_o);
assert(bo->ws_o->e <= (char*)ptr + ltot);
HTTP_Setup(o->http, bo->ws_o, bo->vsl, SLT_ObjMethod);
o->http->magic = HTTP_MAGIC;
VTAILQ_INIT(&o->body->list);
o->objcore = bo->fetch_objcore;
......@@ -323,12 +317,11 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
*/
struct object *
STV_NewObject(struct busyobj *bo, const char *hint,
unsigned wsl, uint16_t nhttp)
STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
{
struct object *o;
struct stevedore *stv, *stv0;
unsigned lhttp, ltot;
unsigned ltot;
struct stv_objsecrets soc;
int i;
......@@ -337,16 +330,11 @@ STV_NewObject(struct busyobj *bo, const char *hint,
assert(wsl > 0);
wsl = PRNDUP(wsl);
lhttp = HTTP_estimate(nhttp);
lhttp = PRNDUP(lhttp);
memset(&soc, 0, sizeof soc);
soc.magic = STV_OBJ_SECRETES_MAGIC;
soc.nhttp = nhttp;
soc.lhttp = lhttp;
soc.wsl = wsl;
ltot = sizeof *o + wsl + lhttp;
ltot = sizeof *o + wsl;
stv = stv0 = stv_pick_stevedore(bo->vsl, &hint);
AN(stv->allocobj);
......
......@@ -2,19 +2,19 @@ varnishtest "Object/LRU/Stevedores"
server s1 {
rxreq
txresp -bodylen 1048190
txresp -bodylen 1048290
rxreq
txresp -bodylen 1048191
txresp -bodylen 1048291
rxreq
txresp -bodylen 1048192
txresp -bodylen 1048292
rxreq
txresp -bodylen 1047193
txresp -bodylen 1047293
rxreq
txresp -bodylen 1047194
txresp -bodylen 1047294
} -start
varnish v1 \
......@@ -35,7 +35,7 @@ client c1 {
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.bodylen == 1048190
expect resp.bodylen == 1048290
} -run
varnish v1 -expect SMA.Transient.g_bytes == 0
......@@ -50,7 +50,7 @@ client c1 {
txreq -url /bar
rxresp
expect resp.status == 200
expect resp.bodylen == 1048191
expect resp.bodylen == 1048291
} -run
varnish v1 -expect SMA.Transient.g_bytes == 0
......@@ -65,7 +65,7 @@ client c1 {
txreq -url /burp
rxresp
expect resp.status == 200
expect resp.bodylen == 1048192
expect resp.bodylen == 1048292
} -run
varnish v1 -expect SMA.Transient.g_bytes == 0
......@@ -80,7 +80,7 @@ client c1 {
txreq -url /foo1
rxresp
expect resp.status == 200
expect resp.bodylen == 1047193
expect resp.bodylen == 1047293
} -run
varnish v1 -expect n_lru_nuked == 1
......@@ -89,7 +89,7 @@ client c1 {
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.bodylen == 1047194
expect resp.bodylen == 1047294
} -run
varnish v1 -expect n_lru_nuked == 2
......@@ -2,11 +2,11 @@ varnishtest "Object/LRU/Stevedores with hinting"
server s1 {
rxreq
txresp -bodylen 1048188
txresp -bodylen 1048288
rxreq
txresp -bodylen 1047189
txresp -bodylen 1047289
rxreq
txresp -bodylen 1047190
txresp -bodylen 1047290
} -start
varnish v1 \
......@@ -27,7 +27,7 @@ client c1 {
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.bodylen == 1048188
expect resp.bodylen == 1048288
} -run
varnish v1 -expect SMA.Transient.g_bytes == 0
......@@ -42,7 +42,7 @@ client c1 {
txreq -url /bar
rxresp
expect resp.status == 200
expect resp.bodylen == 1047189
expect resp.bodylen == 1047289
} -run
varnish v1 -expect n_lru_nuked == 1
......@@ -58,7 +58,7 @@ client c1 {
txreq -url /foo
rxresp
expect resp.status == 200
expect resp.bodylen == 1047190
expect resp.bodylen == 1047290
} -run
varnish v1 -expect n_lru_nuked == 2
......
......@@ -4,7 +4,7 @@ server s1 {
# This response should almost completely fill the storage
rxreq
expect req.url == /url1
txresp -bodylen 1048208
txresp -bodylen 1048308
# The next one should not fit in the storage, ending up in transient
# with zero ttl (=shortlived)
......@@ -31,7 +31,7 @@ client c1 {
txreq -url /url1
rxresp
expect resp.status == 200
expect resp.bodylen == 1048208
expect resp.bodylen == 1048308
} -run
delay .1
......
......@@ -3,7 +3,7 @@ varnishtest "#1284 - Test resource cleanup after STV_NewObject fail in fetch"
server s1 {
rxreq
expect req.url == "/obj1"
txresp -bodylen 1048190
txresp -bodylen 1048290
rxreq
expect req.url == "/obj2"
txresp -hdr "Long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -hdr "Long2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
......
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