Commit 2e583c94 authored by Geoff Simmons's avatar Geoff Simmons

remove the xid field from the data entry struct

parent 995fd679
...@@ -310,6 +310,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -310,6 +310,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
int status = DISPATCH_RETURN_OK; int status = DISPATCH_RETURN_OK;
dataentry *de = NULL; dataentry *de = NULL;
char reqend_str[REQEND_T_LEN]; char reqend_str[REQEND_T_LEN];
int32_t vxid;
(void) priv; (void) priv;
if (all_wrk_abandoned()) if (all_wrk_abandoned())
...@@ -344,7 +345,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -344,7 +345,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
assert(VSL_CLIENT(t->c->rec.ptr)); assert(VSL_CLIENT(t->c->rec.ptr));
if (de->end == 0) { if (de->end == 0) {
de->xid = t->vxid; vxid = t->vxid;
snprintf(de->data, config.max_reclen, "XID=%u", t->vxid); snprintf(de->data, config.max_reclen, "XID=%u", t->vxid);
de->end = strlen(de->data); de->end = strlen(de->data);
if (de->end > len_hi) if (de->end > len_hi)
...@@ -423,7 +424,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -423,7 +424,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
snprintf(reqend_str, REQEND_T_LEN, "%s=%u.%06lu", REQEND_T_VAR, snprintf(reqend_str, REQEND_T_LEN, "%s=%u.%06lu", REQEND_T_VAR,
(unsigned) de->reqend_t.tv_sec, de->reqend_t.tv_usec); (unsigned) de->reqend_t.tv_sec, de->reqend_t.tv_usec);
append(de, SLT_Timestamp, de->xid, reqend_str, REQEND_T_LEN - 1); append(de, SLT_Timestamp, vxid, reqend_str, REQEND_T_LEN - 1);
de->occupied = 1; de->occupied = 1;
MON_StatsUpdate(STATS_OCCUPANCY, 0); MON_StatsUpdate(STATS_OCCUPANCY, 0);
data_submit(de); data_submit(de);
......
...@@ -112,7 +112,6 @@ DATA_Reset(dataentry *entry) ...@@ -112,7 +112,6 @@ DATA_Reset(dataentry *entry)
entry->keylen = 0; entry->keylen = 0;
*entry->key = '\0'; *entry->key = '\0';
entry->hasdata = 0; entry->hasdata = 0;
entry->xid = 0;
entry->reqend_t.tv_sec = 0; entry->reqend_t.tv_sec = 0;
entry->reqend_t.tv_usec = 0; entry->reqend_t.tv_usec = 0;
} }
...@@ -158,8 +157,8 @@ DATA_Dump(void) ...@@ -158,8 +157,8 @@ DATA_Dump(void)
if (!OCCUPIED(entry)) if (!OCCUPIED(entry))
continue; continue;
LOG_Log(LOG_INFO, LOG_Log(LOG_INFO,
"Data entry %d: XID=%u data=[%.*s] key=[%.*s] reqend_t=%u.%06u", "Data entry %d: data=[%.*s] key=[%.*s] reqend_t=%u.%06u",
i, entry->xid, entry->end, entry->data, entry->keylen, i, entry->end, entry->data, entry->keylen, entry->key,
entry->key, entry->reqend_t.tv_sec, entry->reqend_t.tv_usec); entry->reqend_t.tv_sec, entry->reqend_t.tv_usec);
} }
} }
...@@ -63,7 +63,6 @@ static char ...@@ -63,7 +63,6 @@ static char
MAZ(entrytbl[i].hasdata); MAZ(entrytbl[i].hasdata);
MAN(entrytbl[i].data); MAN(entrytbl[i].data);
MAN(entrytbl[i].key); MAN(entrytbl[i].key);
MAZ(entrytbl[i].xid);
MAZ(entrytbl[i].end); MAZ(entrytbl[i].end);
MAZ(entrytbl[i].keylen); MAZ(entrytbl[i].keylen);
MAZ(entrytbl[i].reqend_t.tv_sec); MAZ(entrytbl[i].reqend_t.tv_sec);
......
...@@ -29,10 +29,11 @@ ...@@ -29,10 +29,11 @@
* *
*/ */
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <errno.h> #include <errno.h>
#include <stdint.h>
#include <inttypes.h>
#include "minunit.h" #include "minunit.h"
...@@ -57,7 +58,7 @@ typedef enum { ...@@ -57,7 +58,7 @@ typedef enum {
} fail_e; } fail_e;
typedef struct { typedef struct {
unsigned sum; uintptr_t sum;
fail_e fail; fail_e fail;
} prod_con_data_t; } prod_con_data_t;
...@@ -78,20 +79,15 @@ static void ...@@ -78,20 +79,15 @@ static void
(void) arg; (void) arg;
srand48(time(NULL));
unsigned xid = (unsigned int) lrand48();
for (int i = 0; i < config.max_records; i++) { for (int i = 0; i < config.max_records; i++) {
entries[i].xid = xid; debug_print("Producer: enqueue %d\n", ++enqs);
debug_print("Producer: enqueue %d (xid = %u)\n", ++enqs, xid);
SPMCQ_Enq(&entries[i]); SPMCQ_Enq(&entries[i]);
debug_print("%s\n", "Producer: broadcast"); debug_print("%s\n", "Producer: broadcast");
if (pthread_cond_broadcast(&spmcq_datawaiter_cond) != 0) { if (pthread_cond_broadcast(&spmcq_datawaiter_cond) != 0) {
proddata.fail = PRODUCER_BCAST; proddata.fail = PRODUCER_BCAST;
pthread_exit(&proddata); pthread_exit(&proddata);
} }
proddata.sum += xid; proddata.sum += (uintptr_t) entries[i].data;
xid++;
} }
debug_print("%s\n", "Producer: exit"); debug_print("%s\n", "Producer: exit");
pthread_exit((void *) &proddata); pthread_exit((void *) &proddata);
...@@ -138,16 +134,14 @@ static void ...@@ -138,16 +134,14 @@ static void
} }
} else { } else {
/* entry != NULL */ /* entry != NULL */
debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs, debug_print("Consumer %d: dequeue %d\n", id, ++deqs);
entry->xid); pcdata->sum += (uintptr_t) entry->data;
pcdata->sum += entry->xid;
} }
} }
debug_print("Consumer %d: drain queue, run = %d\n", id, run); debug_print("Consumer %d: drain queue, run = %d\n", id, run);
while ((entry = SPMCQ_Deq()) != NULL) { while ((entry = SPMCQ_Deq()) != NULL) {
debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs, debug_print("Consumer %d: dequeue %d\n", id, ++deqs);
entry->xid); pcdata->sum += (uintptr_t) entry->data;
pcdata->sum += entry->xid;
} }
debug_print("Consumer %d: exit\n", id); debug_print("Consumer %d: exit\n", id);
pthread_exit((void *) pcdata); pthread_exit((void *) pcdata);
...@@ -181,18 +175,15 @@ static char ...@@ -181,18 +175,15 @@ static char
static const char static const char
*test_spmcq_enq_deq(void) *test_spmcq_enq_deq(void)
{ {
#define XID 1234567890
dataentry entry1, *entry2; dataentry entry1, *entry2;
printf("... testing SPMCQ enqueue and dequeue\n"); printf("... testing SPMCQ enqueue and dequeue\n");
entry1.xid = 1234567890;
SPMCQ_Enq(&entry1); SPMCQ_Enq(&entry1);
entry2 = SPMCQ_Deq(); entry2 = SPMCQ_Deq();
mu_assert("SPMCQ_Deq: returned NULL from non-empty queue", entry2 != NULL); mu_assert("SPMCQ_Deq: returned NULL from non-empty queue", entry2 != NULL);
sprintf(errmsg, "SMPCQ_Deq: expected %d, got %d", XID, entry2->xid); MASSERT(&entry1 == entry2);
mu_assert(errmsg, XID == entry2->xid);
return NULL; return NULL;
} }
...@@ -267,8 +258,9 @@ static const char ...@@ -267,8 +258,9 @@ static const char
mu_assert(errmsg, con2_data->fail == SUCCESS); mu_assert(errmsg, con2_data->fail == SUCCESS);
} }
sprintf(errmsg, "Consumer/producer checksum mismatch: p = %u, c = %u", sprintf(errmsg, "Consumer/producer checksum mismatch: p = %" PRIuPTR
prod_data->sum, con1_data->sum + con2_data->sum); ", c = %" PRIuPTR,
prod_data->sum, con1_data->sum + con2_data->sum);
mu_assert(errmsg, prod_data->sum == con1_data->sum + con2_data->sum); mu_assert(errmsg, prod_data->sum == con1_data->sum + con2_data->sum);
return NULL; return NULL;
......
...@@ -129,9 +129,6 @@ static const char ...@@ -129,9 +129,6 @@ static const char
printf("... testing run of %d workers\n", NWORKERS); printf("... testing run of %d workers\n", NWORKERS);
srand48(time(NULL));
unsigned xid = (unsigned int) lrand48();
WRK_Start(); WRK_Start();
int wrk_running, wrk_wait = 0; int wrk_running, wrk_wait = 0;
while ((wrk_running = WRK_Running()) < NWORKERS) { while ((wrk_running = WRK_Running()) < NWORKERS) {
...@@ -145,8 +142,7 @@ static const char ...@@ -145,8 +142,7 @@ static const char
for (int i = 0; i < config.max_records; i++) { for (int i = 0; i < config.max_records; i++) {
entry = &entrytbl[i]; entry = &entrytbl[i];
MCHECK_OBJ_NOTNULL(entry, DATA_MAGIC); MCHECK_OBJ_NOTNULL(entry, DATA_MAGIC);
entry->xid = xid; sprintf(entry->data, "foo=bar&baz=quux&record=%d", i+1);
sprintf(entry->data, "XID=%d&foo=bar&baz=quux&record=%d", xid, i+1);
entry->end = strlen(entry->data); entry->end = strlen(entry->data);
entry->occupied = 1; entry->occupied = 1;
SPMCQ_Enq(entry); SPMCQ_Enq(entry);
...@@ -171,7 +167,6 @@ static const char ...@@ -171,7 +167,6 @@ static const char
MAZ(entry->keylen); MAZ(entry->keylen);
MAZ(*entry->key); MAZ(*entry->key);
MAZ(entry->hasdata); MAZ(entry->hasdata);
MAZ(entry->xid);
MAZ(entry->reqend_t.tv_sec); MAZ(entry->reqend_t.tv_sec);
MAZ(entry->reqend_t.tv_usec); MAZ(entry->reqend_t.tv_usec);
} }
......
...@@ -122,7 +122,6 @@ struct dataentry_s { ...@@ -122,7 +122,6 @@ struct dataentry_s {
VSTAILQ_ENTRY(dataentry_s) spmcq; VSTAILQ_ENTRY(dataentry_s) spmcq;
struct timeval reqend_t; struct timeval reqend_t;
unsigned xid;
unsigned end; /* End of string index in data */ unsigned end; /* End of string index in data */
unsigned keylen; unsigned keylen;
......
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