Commit 73921013 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Pack struct ws better to avoid padding.

Repack struct object, reducing a couple of field widths along the way.

This shaves 16 bytes of struct object.
parent ece423dc
......@@ -143,12 +143,12 @@ enum step {
struct ws {
unsigned magic;
#define WS_MAGIC 0x35fac554
unsigned overflow; /* workspace overflowed */
const char *id; /* identity */
char *s; /* (S)tart of buffer */
char *f; /* (F)ree pointer */
char *r; /* (R)eserved length */
char *e; /* (E)nd of buffer */
int overflow; /* workspace overflowed */
};
/*--------------------------------------------------------------------
......@@ -479,12 +479,13 @@ struct object {
struct objcore *objcore;
struct ws ws_o[1];
unsigned char *vary;
unsigned response;
uint8_t *vary;
unsigned hits;
uint16_t response;
/* XXX: make bitmap */
unsigned gziped;
uint8_t gziped;
/* Bit positions in the gzip stream */
ssize_t gzip_start;
ssize_t gzip_last;
......@@ -507,7 +508,6 @@ struct object {
double last_use;
int hits;
};
/* -------------------------------------------------------------------*/
......@@ -566,7 +566,7 @@ struct sess {
unsigned handling;
unsigned char sendbody;
unsigned char wantbody;
int err_code;
uint16_t err_code;
const char *err_reason;
VTAILQ_ENTRY(sess) list;
......
......@@ -38,6 +38,7 @@
#include <stdio.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
......@@ -124,7 +125,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
(void)priv;
#define SZOF(foo) VCLI_Out(cli, \
"sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo));
"sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo))
SZOF(struct ws);
SZOF(struct http);
SZOF(struct http_conn);
......@@ -139,6 +140,63 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
SZOF(struct vbc);
SZOF(struct VSC_C_main);
SZOF(struct lock);
#define OFOF(foo, bar) { foo __foo; VCLI_Out(cli, \
"%-30s = 0x%4zx @ 0x%4zx\n", \
#foo "." #bar, sizeof(__foo.bar), offsetof(foo, bar)); }
#if 0
OFOF(struct objhead, magic);
OFOF(struct objhead, refcnt);
OFOF(struct objhead, mtx);
OFOF(struct objhead, objcs);
OFOF(struct objhead, digest);
OFOF(struct objhead, waitinglist);
OFOF(struct objhead, _u);
#endif
#if 0
OFOF(struct http, magic);
OFOF(struct http, logtag);
OFOF(struct http, ws);
OFOF(struct http, hd);
OFOF(struct http, hdf);
OFOF(struct http, shd);
OFOF(struct http, nhd);
OFOF(struct http, status);
OFOF(struct http, protover);
OFOF(struct http, conds);
#endif
#if 0
OFOF(struct storage, magic);
OFOF(struct storage, fd);
OFOF(struct storage, where);
OFOF(struct storage, list);
OFOF(struct storage, stevedore);
OFOF(struct storage, priv);
OFOF(struct storage, ptr);
OFOF(struct storage, len);
OFOF(struct storage, space);
#endif
OFOF(struct object, magic);
OFOF(struct object, xid);
OFOF(struct object, objstore);
OFOF(struct object, objcore);
OFOF(struct object, ws_o);
OFOF(struct object, vary);
OFOF(struct object, hits);
OFOF(struct object, response);
OFOF(struct object, gziped);
OFOF(struct object, gzip_start);
OFOF(struct object, gzip_last);
OFOF(struct object, gzip_stop);
OFOF(struct object, len);
OFOF(struct object, age);
OFOF(struct object, entered);
OFOF(struct object, exp);
OFOF(struct object, last_modified);
OFOF(struct object, last_lru);
OFOF(struct object, http);
OFOF(struct object, store);
OFOF(struct object, esidata);
OFOF(struct object, last_use);
}
/*--------------------------------------------------------------------*/
......
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