Commit 6d68ffef authored by Geoff Simmons's avatar Geoff Simmons

added FMT_Estimate_RecsPerTx() (not tested yet)

parent 95f6f8d8
......@@ -53,8 +53,6 @@
} \
} while (0)
#define FAKE_DEFAULT_LINES_PER_TX 10
static const char *statename[3] = { "EMPTY", "DONE" };
static pthread_mutex_t freetx_lock = PTHREAD_MUTEX_INITIALIZER;
......@@ -65,8 +63,6 @@ static txhead_t freetxhead;
static linehead_t freelinehead;
static chunkhead_t freechunkhead;
static int lines_per_tx = FAKE_DEFAULT_LINES_PER_TX;
static void
data_Cleanup(void)
{
......@@ -109,13 +105,8 @@ DATA_Clear_Tx(tx_t *tx)
int
DATA_Init(void)
{
int bufidx = 0, chunks_per_rec;
#if 0
lines_per_tx = FMT_Get_LinesPerTx();
#endif
int bufidx = 0, chunks_per_rec, lines_per_tx = FMT_Estimate_RecsPerTx();
/* XXX: set up tables of txen, lines & chunks, set/estimate sizes */
nrecords = config.max_data * lines_per_tx;
AN(config.chunk_size);
chunks_per_rec
......
......@@ -1096,6 +1096,61 @@ FMT_Get_i_Arg(void)
return VSB_data(i_arg);
}
int
FMT_Estimate_RecsPerTx(void)
{
int recs_per_tx = 0, recs_per_ctx = 0, recs_per_btx = 0;
for (int i = 0; i < MAX_VSL_TAG; i++) {
if (rtags[i]) {
recs_per_tx = 1;
break;
}
}
for (int i = 0; i < MAX_VSL_TAG; i++) {
if (ctags[i]) {
switch(i) {
case SLT_ReqHeader:
case SLT_RespHeader:
recs_per_ctx += config.max_headers;
break;
case SLT_VCL_call:
case SLT_VCL_return:
recs_per_ctx += config.max_vcl_call;
break;
case SLT_Timestamp:
recs_per_ctx += config.max_timestamp;
break;
default:
recs_per_ctx++;
}
}
}
if (recs_per_ctx > recs_per_tx)
recs_per_tx = recs_per_ctx;
for (int i = 0; i < MAX_VSL_TAG; i++) {
if (btags[i]) {
switch(i) {
case SLT_BereqHeader:
case SLT_BerespHeader:
recs_per_btx += config.max_headers;
break;
case SLT_Timestamp:
recs_per_ctx += config.max_timestamp;
break;
default:
recs_per_ctx++;
}
}
}
if (recs_per_btx > recs_per_tx)
recs_per_tx = recs_per_btx;
return recs_per_tx;
}
void
FMT_Format(tx_t *tx, struct vsb *os)
{
......
......@@ -13,6 +13,8 @@ test_data_LDADD = \
../config.$(OBJEXT) \
../log.$(OBJEXT) \
../data.$(OBJEXT) \
../format.$(OBJEXT) \
../strfTIM.$(OBJEXT) \
@VARNISH_LIBS@ @VARNISH_LIBVARNISH_LIB@ -lm -lvarnish
test_format_SOURCES = \
......
......@@ -46,14 +46,14 @@ static char
*test_data_init(void)
{
int err;
char fmterr[BUFSIZ];
printf("... testing data table initialization\n");
MAZ(LOG_Open("test_data"));
CONF_Init();
#if 0
MAZ(FMT_Init(fmterr));
#endif
VMASSERT((err = DATA_Init()) == 0, "DATA_Init: %s", strerror(err));
MAN(txn);
......
......@@ -561,12 +561,10 @@ main(int argc, char *argv[])
VAS_Fail = assert_fail;
#if 0
if (FMT_Init(scratch) != 0) {
LOG_Log(LOG_ALERT, "Error in output formats: %s", scratch);
exit(EXIT_FAILURE);
}
#endif
if (!EMPTY(config.varnish_bindump))
LOG_Log(LOG_INFO, "Reading from file: %s", config.varnish_bindump);
......@@ -578,9 +576,7 @@ main(int argc, char *argv[])
LOG_Log(LOG_INFO, "Reading varnish instance %s", scratch);
}
#if 0
strcpy(scratch, FMT_Get_i_Arg());
#endif
if (EMPTY(scratch)) {
LOG_Log0(LOG_ALERT, "Not configured to read any log data, exiting");
exit(EXIT_FAILURE);
......@@ -666,9 +662,7 @@ main(int argc, char *argv[])
WRT_Halt();
SPSCQ_Shutdown();
MON_Shutdown();
#if 0
FMT_Shutdown();
#endif
FMT_Fini();
AZ(pthread_cond_destroy(&data_ready_cond));
AZ(pthread_mutex_destroy(&data_ready_lock));
AZ(pthread_cond_destroy(&spscq_ready_cond));
......
......@@ -191,9 +191,9 @@ struct config {
/* varnishd param http_max_hdr */
unsigned max_headers;
unsigned max_vcl_log;
unsigned max_vcl_call;
unsigned max_timestamp;
unsigned max_fd;
unsigned max_data;
......@@ -284,6 +284,7 @@ void MON_Output(void);
/* format.c */
int FMT_Init(char *err);
char *FMT_Get_i_Arg(void);
int FMT_Estimate_RecsPerTx(void);
void FMT_Format(tx_t *tx, struct vsb *os);
void FMT_Fini(void);
......
......@@ -177,9 +177,7 @@ wrt_write(tx_t *tx)
AZ(pthread_mutex_unlock(&reopen_lock));
VSB_clear(os);
#if 0
FMT_Format(tx, os);
#endif
VSB_finish(os);
if (timeout != NULL)
......
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